-
Notifications
You must be signed in to change notification settings - Fork 2k
Go: Add JWT Algorithm Confusion and JWT decoding without Signature Verification #14081
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4f2d15e
Initial JWT Library
Kwstubbs fafdee5
Finish
Kwstubbs 7730ad6
Finish
Kwstubbs 8d2bc38
removed user files
Kwstubbs 01a28eb
update docs
Kwstubbs 1d6a805
Spelling
Kwstubbs ecbde43
Formatting and errors
Kwstubbs 3a2b66e
change note
Kwstubbs 1370bac
Big upgrade
Kwstubbs 21fa77d
grammar
Kwstubbs 84359fe
Finish
Kwstubbs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Formatting and errors
- Loading branch information
commit ecbde43663c064d15c9be852b763a9958d9a768b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,74 +1,87 @@ | ||
| /** Provides models of commonly used functions in common JWT packages. */ | ||
|
|
||
| import go | ||
|
|
||
| /** | ||
| * Provides models of commonly used functions in common JWT packages. | ||
| */ | ||
| module JWT { | ||
| string packageLestrrat() { result = package("github.com/lestrrat-go/jwx/v2/jwt", "") } | ||
|
|
||
| string packageLestrrat() { | ||
| result = | ||
| package("github.com/lestrrat-go/jwx/v2/jwt", "") | ||
| string packageLestrratv1() { result = package("github.com/lestrrat-go/jwx/jwt", "") } | ||
|
Kwstubbs marked this conversation as resolved.
|
||
|
|
||
| } | ||
| string packageLestrratv1() { | ||
| result = | ||
| package("github.com/lestrrat-go/jwx/jwt", "") | ||
| } | ||
| string packagePathModern() { | ||
| result = | ||
| package(["github.com/golang-jwt/jwt/v5", "github.com/golang-jwt/jwt/v4"], "") | ||
| string packagePathModern() { | ||
| result = package(["github.com/golang-jwt/jwt/v5", "github.com/golang-jwt/jwt/v4"], "") | ||
|
Kwstubbs marked this conversation as resolved.
|
||
| } | ||
| string packagePathOld(){ | ||
| result = | ||
| package( | ||
| "github.com/golang-jwt/jwt", "") | ||
| } | ||
|
|
||
|
|
||
| string packagePathOld() { result = package("github.com/golang-jwt/jwt", "") } | ||
|
|
||
| class NewParser extends Function { | ||
| NewParser() { | ||
| this.hasQualifiedName([packagePathModern()], "NewParser") | ||
| } | ||
| /** | ||
| * Call in golang-jwt to create new parser. | ||
| */ | ||
| NewParser() { this.hasQualifiedName(packagePathModern(), "NewParser") } | ||
| } | ||
|
|
||
| class WithValidMethods extends Function{ | ||
| WithValidMethods() { | ||
| this.hasQualifiedName([packagePathModern()], "WithValidMethods") | ||
| } | ||
|
|
||
| class WithValidMethods extends Function { | ||
| /** | ||
| * Call to WithValidMethods in golang-jwt to specify allowed algorithms. | ||
| */ | ||
| WithValidMethods() { this.hasQualifiedName(packagePathModern(), "WithValidMethods") } | ||
| } | ||
|
|
||
| class SafeJWTParserMethod extends Method { | ||
| SafeJWTParserMethod() { | ||
|
|
||
| class SafeJwtParserMethod extends Method { | ||
| /** | ||
| * Methods to parse token that check token signature. | ||
| */ | ||
| SafeJwtParserMethod() { | ||
| this.hasQualifiedName(packagePathModern(), "Parser", ["Parse", "ParseWithClaims"]) | ||
| } | ||
| } | ||
|
|
||
| class SafeJWTParserFunc extends Function{ | ||
| SafeJWTParserFunc(){ | ||
| this.hasQualifiedName([packagePathModern(),packagePathOld()], ["Parse", "ParseWithClaims"]) | ||
|
|
||
| class SafeJwtParserFunc extends Function { | ||
| /** | ||
| * Functions to parse token that check token signature. | ||
| */ | ||
| SafeJwtParserFunc() { | ||
| this.hasQualifiedName([packagePathModern(), packagePathOld()], ["Parse", "ParseWithClaims"]) | ||
| } | ||
| } | ||
|
|
||
| class UnafeJWTParserMethod extends Method{ | ||
| UnafeJWTParserMethod(){ | ||
| this.hasQualifiedName(packagePathModern(), "Parser", "ParseUnverified") | ||
|
|
||
| class UnafeJwtParserMethod extends Method { | ||
|
Kwstubbs marked this conversation as resolved.
|
||
| /** | ||
| * Methods to parse token that don't token signature. | ||
| */ | ||
| UnafeJwtParserMethod() { | ||
| this.hasQualifiedName(packagePathModern(), "Parser", "ParseUnverified") | ||
| } | ||
| } | ||
| class LestrratParse extends Function{ | ||
| LestrratParse() { | ||
| this.hasQualifiedName(packageLestrrat(), "Parse") | ||
| } | ||
|
|
||
| class LestrratParse extends Function { | ||
| /** | ||
| * v2 Function to parse token that check token signature. | ||
| */ | ||
| LestrratParse() { this.hasQualifiedName(packageLestrrat(), "Parse") } | ||
| } | ||
|
Comment on lines
+64
to
+69
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This model isn't used anywhere. Did you mean to use it somewhere? Or did you model it for completeness? Consider deleting - the model can easily be added in future if it is needed. |
||
| class LestrratParsev1 extends Function{ | ||
| LestrratParsev1() { | ||
| this.hasQualifiedName(packageLestrratv1(), "Parse") | ||
| } | ||
|
|
||
| class LestrratParsev1 extends Function { | ||
| /** | ||
| * v1 Function to parse token that check token signature. | ||
| */ | ||
| LestrratParsev1() { this.hasQualifiedName(packageLestrratv1(), "Parse") } | ||
| } | ||
|
|
||
| class LestrratVerify extends Function { | ||
| LestrratVerify() { | ||
| this.hasQualifiedName(packageLestrratv1(), "WithVerify") | ||
| } | ||
| } | ||
| class LestrratParseInsecure extends Function{ | ||
| LestrratParseInsecure() { | ||
| this.hasQualifiedName(packageLestrrat(), "ParseInsecure") | ||
| } | ||
| /** | ||
| * Funciton included as parse option to verify token. | ||
| */ | ||
| LestrratVerify() { this.hasQualifiedName(packageLestrratv1(), "WithVerify") } | ||
| } | ||
|
|
||
| class LestrratParseInsecure extends Function { | ||
| /** | ||
| * Funciton to parse token that don't check signature. | ||
| */ | ||
| LestrratParseInsecure() { this.hasQualifiedName(packageLestrrat(), "ParseInsecure") } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| | JWTParsingAlgorithim.go:20:4:23:5 | call to Parse | This Parse Call to Verify the JWT token is vulnerable to algorithim confusion | | ||
| | JWTParsingAlgorithim.go:38:22:41:5 | call to Parse | This Parse Call to Verify the JWT token is vulnerable to algorithim confusion | | ||
| | JWTParsingAlgorithm.go:20:4:23:5 | call to Parse | This Parse Call to Verify the JWT token may be vulnerable to algorithim confusion | | ||
| | JWTParsingAlgorithm.go:38:22:41:5 | call to Parse | This Parse Call to Verify the JWT token may be vulnerable to algorithim confusion | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| experimental/CWE-347/JWTParsingAlgorithim.ql | ||
| experimental/CWE-347/JWTParsingAlgorithm.ql |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.