Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Validate bewit MAC before expiry #291

Merged
merged 1 commit into from
Jun 15, 2023
Merged

Conversation

thusoy
Copy link
Contributor

@thusoy thusoy commented Jun 14, 2023

Checking expiry before validating the MAC means that we are passing untrusted values into parseInt, which might have unintended consequences (also consider other languages that copy the algorithm here since this is the reference implementation). This is only done in the wrong order for bewit validation, regular header auth already checks the MAC first.

Had to update the other expiry test since it apparently didn't have a valid MAC.

Checking expiry before validating the MAC means that we are passing
untrusted values into parseInt, which might have unintended
consequences (also consider other languages that copy the algorithm
here since this is the reference implementation). This is only done
in the wrong order for bewit validation, regular header auth already
checks the MAC first.

Had to update the other expiry test since it apparently didn't have a
valid MAC.
@@ -377,7 +377,7 @@ exports.authenticateBewit = async function (req, credentialsFunc, options) {

const bewit = {
id: bewitParts[0],
exp: parseInt(bewitParts[1], 10),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this parsing until after the mac has been validated.

Copy link
Contributor

@lotas lotas left a comment

Choose a reason for hiding this comment

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

Yes, this is reasonable, thank you!

@lotas lotas merged commit fe746ef into mozilla:main Jun 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants