Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw UnsupportedError on unknown algorithm in keys, signatures and encrypted session keys #1523

Merged
merged 9 commits into from Jun 7, 2022

Conversation

larabr
Copy link
Collaborator

@larabr larabr commented May 23, 2022

With this change, the relevant packets will be considered unsupported instead of malformed.

To merge after #1522 .

@larabr larabr requested a review from twiss May 23, 2022 15:16
src/packet/public_key.js Outdated Show resolved Hide resolved
Comment on lines 158 to 162
} catch (err) {
if (err instanceof UnsupportedError) throw err;
// avoid throwing potentially sensitive errors
throw new Error('Error reading MPIs');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - can it throw anything else? And, is the UnsupportedError sensitive, here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is parsing secret key material, so I'd rather not risk it. Even an MPI-bad-length error can be sensitive.
The Unsupported error is only thrown on wrong algo, which is already public information, so it's not sensitive, at least for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even an MPI-bad-length error can be sensitive

But do we throw any such error? From looking at the code I think we just return a Uint8Array with a different length in that case

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the only thing that can throw is the Curve constructor (which can throw "Not valid curve"), but actually that should probably be an UnsupportedError as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the declared length is too long, is it guaranteed that .subarray doesn't throw? Is it not up to the platform?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's guaranteed, see mdn / tc39

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're temporarily leaving the if-else here; #1523 is a more permanent solution to avoid not hiding sensitive errors introduced by future changes.

src/crypto/crypto.js Outdated Show resolved Hide resolved
@larabr larabr force-pushed the parse-unknown-key-algorithms branch from bba4451 to 3fd57a8 Compare May 26, 2022 13:50
src/crypto/crypto.js Outdated Show resolved Hide resolved
@larabr larabr changed the title Throw UnsupportedError on unknown algorithm in keys and signatures Throw UnsupportedError on unknown algorithm in keys, signatures and encrypted session keys Jun 3, 2022
@larabr larabr requested a review from twiss June 3, 2022 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants