mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
* fix(security): reject unregistered SigV4 access keys and unbound usernames
SigV4Validator.java and RdsSigV4Validator.java both fell back to
`iamService.findSecretKey(accessKeyId).orElse(accessKeyId)` when the
access key wasn't registered. Since the attacker chooses accessKeyId
themselves, they can self-sign a token using secret == accessKeyId,
producing the exact signing key this fallback derives -- a full
signature-forgery auth bypass for any unregistered IAM key. Both now
fail closed when the key isn't registered.
SigV4Validator's ElastiCache username binding
(`expectedUsername != null && user != null && !expectedUsername.equals(user)`)
also skipped the check whenever the token simply omitted the User
query param, letting any expectedUsername through. Dropped the
`user != null` conjunct so a null user now correctly fails the check.
Each fix has a RED test proving the exploit against the unpatched
code (self-signed token with secret == accessKeyId; token missing
User) before asserting the fixed behavior.
RdsSigV4Validator's DBUser check was investigated but is not
vulnerable: DBUser is already required by the missing-parameters
check above it, so the null-skip path is unreachable via a crafted
token. PreSignedUrlFilter's well-known "test"/"test" credential and
its lack of a bucket-ownership check were also investigated and are
not presigned-URL-specific bugs -- see
issues/sigv4-review-remaining-findings.md for the evidence and for
everything else from the review pass deferred out of this PR.
* fix(security): restore well-known local-dev credential, sanitize log lines
The fail-closed fix in the prior commit broke the emulator's default
local-dev credential flow: AwsBasicCredentials.create("test", "test")
is used pervasively by SDK clients against RDS/ElastiCache IAM auth
(and S3) in this project's compat test suite, and was never actually
registered in IamService -- it only "worked" before because the
vulnerable fallback happened to derive the same secret ("test") from
the access key ID by coincidence (accessKeyId == secretKey == "test").
Carve out that exact, already-public pair explicitly in both
validators, mirroring the identical LEGACY_ACCESS_KEY_ID/SECRET_KEY
idiom already used by S3Service/PreSignedUrlFilter -- this does not
reopen the forgery bug, since it only ever matches the literal string
"test", never an attacker-chosen access key.
Also addresses two Copilot review comments: the debug logs added in
the fail-closed fix (and the pre-existing signature-mismatch log)
interpolated the attacker-controlled, URL-decoded accessKeyId with no
sanitization, allowing CR/LF-based log injection. Added a
sanitizeForLog helper (strips control characters) and applied it to
every log line that includes accessKeyId in both files.
* docs(security): update ledger after rebasing past PR #2657's merge
PR #2657 merged with the misleading "always fails the signature check"
comment in both SigV4Validator.java and RdsSigV4Validator.java (not
just the ElastiCache file, as first flagged). Rebasing this branch
onto upstream/main produced real conflicts on both files; resolved by
keeping the fail-closed fix and dropping the comment. Updated the
ledger from future-tense speculation to the resolved outcome.