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

fix(secret): use .eyJ keyword for JWT secret #7410

Merged

Conversation

DmitriyLewen
Copy link
Contributor

@DmitriyLewen DmitriyLewen commented Aug 28, 2024

Description

use .eyJ keyword for JWT secret

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@DmitriyLewen DmitriyLewen self-assigned this Aug 28, 2024
@DmitriyLewen DmitriyLewen marked this pull request as ready for review August 28, 2024 03:12
@DmitriyLewen DmitriyLewen requested a review from knqyf263 as a code owner August 28, 2024 03:12
@knqyf263
Copy link
Collaborator

I think .eyJ is better.

  1. JWT headers typically start with {".
  2. ASCII codes:
    • {: 123 (01111011 in binary)
    • ": 34 (00100010 in binary)
  3. Combining these: 011110110010001
  4. Grouping into 6-bit segments: 011110 | 110010 | 0010xx
  5. Decimal values: 30 | 50 | ?
  6. Base64 encoded: e | y | ?
  7. The next character is often 'J' because:
    • The third character in the JWT header is usually the start of a key (e.g., "alg" or "typ").
    • All a-zA-Z characters start with '01' in binary.
    • When grouped with the previous bits: 011110 | 110010 | 001001
    • The third group (001001) is 9 in decimal, which corresponds to 'J' in Base64.

Therefore, JWTs typically start with "eyJ". The second body also starts with eyJ, leading to .eyJ in the entire payload.

@DmitriyLewen
Copy link
Contributor Author

Wow, nice logical chain 👍
I updated keywords in 1e6a54a

@knqyf263 knqyf263 changed the title fix(secret): use .ey keyword for JWT secret fix(secret): use .eyJ keyword for JWT secret Aug 30, 2024
@knqyf263 knqyf263 added this pull request to the merge queue Aug 30, 2024
Merged via the queue into aquasecurity:main with commit bf64003 Aug 30, 2024
14 checks passed
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.

JWT secret detector only works if "JWT" word is in scope
2 participants