Skip to content

Commit

Permalink
fix: session.ts Prototype-polluting assignment (#377)
Browse files Browse the repository at this point in the history
This change fixes the CodeQL alerts:
  * https://github.com/opentdf/web-sdk/security/code-scanning/6
  * https://github.com/opentdf/web-sdk/security/code-scanning/7

Fixed by adding validation to ensure that the user supplied `response.state` can not be interpreted in a way that would result in unexpected invocation.
  • Loading branch information
jentfoo authored Nov 18, 2024
1 parent 75ca10c commit 94993bc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions web-app/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,13 @@ export class OidcClient implements AuthProvider {
if (response._ === 'FAIL') {
throw new Error(`OIDC auth ${response.error || 'error'}: [${response.error_description}]`);
}
if (
response.state === '__proto__' ||
response.state === 'constructor' ||
response.state === 'prototype'
) {
throw new Error('Invalid state value');
}
const currentSession = sessions.requests[response.state];
if (!currentSession) {
throw new Error(`OIDC auth error: session storage missing state for ${response}`);
Expand Down

0 comments on commit 94993bc

Please sign in to comment.