Add Rails Master Key detector#5071
Conversation
Add detector for HTTP Basic Authentication tokens (BSCAU002). Detects Authorization: Basic <base64> patterns and decodes them to extract username:password credentials. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements detection and verification for Rails master keys used to encrypt credentials in Ruby on Rails applications (version 5.2+). - Pattern: 32 or 64 hexadecimal characters (16 or 32 bytes) - Verification: Validates hex decoding to correct byte lengths - Keywords: "master", "key", "rails", "secret", "credential" Rails master keys are symmetric encryption keys (not API keys), so verification checks structural validity rather than calling an external API. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Deeraj CM seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 6a83451. Configure here.
|
|
||
| // Rails master keys are 16 bytes (32 hex) or 32 bytes (64 hex) when decoded | ||
| return len(decoded) == 16 || len(decoded) == 32 | ||
| } |
There was a problem hiding this comment.
Tautological verification always returns true for matches
High Severity
verifyRailsMasterKey always returns true for any regex match, making Verified meaningless. The regex ([0-9a-f]{64}|[0-9a-f]{32}) already guarantees the match is exactly 32 or 64 lowercase hex characters, so the length check, hex.DecodeString, and decoded-length check in the function are all tautologically satisfied. Every other detector in the codebase performs actual external verification (e.g., HTTP API calls). Here, any hex string (MD5 hashes, SHA-256 hashes, etc.) near keywords like "key" or "secret" will be reported as a verified Rails master key.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 6a83451. Configure here.


What
Adds detector for Rails Master Keys (symmetric encryption keys from Ruby on Rails)
Why
Rails master keys are sensitive encryption keys that should be detected in code repositories
Changes
Testing
Note
Medium Risk
New credential and encryption-key detection increases scan sensitivity; the Rails hex regex may false-positive on unrelated 32/64-char hex, and Basic Auth findings always surface decoded passwords as unverified secrets.
Overview
Adds two new secret detectors and wires them into the default engine and
DetectorTypeenum (BasicAuth= 1057,RailsMasterKey= 1063).HTTP Basic Auth matches
Authorization/authheaders with aBasicbase64 payload, decodes it, and requires a non-emptyusername:password. Findings are always unverified (no endpoint to validate against) and populateSecretPartsplus decodedRawV2.Rails Master Key matches 32- or 64-character lowercase hex strings (deduped), with optional verification via hex decode length (16 or 32 bytes) and a rotation guide in
ExtraDatawhen verified.Unit tests cover both detectors; Rails also has pattern/verification tests and a
detectors-tag integration test scaffold. Note: the Rails integration test still referencesScanner{client: ...}whileScanneris an empty struct and verification is local-only—those cases may not compile or match runtime behavior until aligned.Reviewed by Cursor Bugbot for commit 6a83451. Bugbot is set up for automated code reviews on this repo. Configure here.