fix: cap expires in and return bad request#1020
Conversation
There was a problem hiding this comment.
Pull request overview
This PR prevents oversized expiresIn values from causing internal signing failures by bounding/validating the parameter and returning a client-facing 400 error instead of a 500 during JWT signing for signed object URLs.
Changes:
- Add a maximum constraint for
expiresInin the signed URL and batch signed URL request schemas. - Harden JWT signing by validating numeric expirations and converting
joseexpiration-setting failures intoInvalidParameter(400). - Add tests to assert oversized
expiresInis rejected for single/batch signed URL routes and forsignJWT().
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/internal/auth/jwt.ts | Adds MAX bound constant and validates/guards expiration handling in signJWT. |
| src/http/routes/object/getSignedURL.ts | Caps expiresIn in the single signed URL route body schema. |
| src/http/routes/object/getSignedURLs.ts | Caps expiresIn in the batch signed URLs route body schema. |
| src/test/jwt.test.ts | Adds coverage ensuring signJWT() rejects oversized numeric expirations as InvalidParameter. |
| src/test/object.test.ts | Adds route-level coverage ensuring oversized expiresIn is rejected before signing (single + batch). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e7e2b1a to
1c2fe6f
Compare
Coverage Report for CI Build 24459457204Coverage increased (+60.4%) to 82.475%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1c2fe6f to
106ae6e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4dc4b68 to
c9e55f2
Compare
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
c9e55f2 to
21b13ea
Compare
What kind of change does this PR introduce?
fix
What is the current behavior?
Schema only validates the type for expiresIn but doesn't cap the max value so invalid value can bubble as 500 while signing.
What is the new behavior?
Cap the value by safe range and bubble it as 400 invalid parameter