add: url signing for onramper widget - #517
Open
L03TJ3 wants to merge 3 commits into
Open
Conversation
8 tasks
Contributor
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- Consider whether allowing
passport.authenticate(['jwt', 'anonymous'])on/verify/onramper/signis intended, as this exposes a generic signing oracle to unauthenticated callers; you may want to require a fully authenticated user or additional checks. - The
signContentvalidation currently treats non-string values the same as missing input; if this endpoint might be used programmatically, distinguishing between missing and invalid types (or coercing viaString(signContent)) could make error handling clearer.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider whether allowing `passport.authenticate(['jwt', 'anonymous'])` on `/verify/onramper/sign` is intended, as this exposes a generic signing oracle to unauthenticated callers; you may want to require a fully authenticated user or additional checks.
- The `signContent` validation currently treats non-string values the same as missing input; if this endpoint might be used programmatically, distinguishing between missing and invalid types (or coercing via `String(signContent)`) could make error handling clearer.
## Individual Comments
### Comment 1
<location path="src/server/verification/verificationAPI.js" line_range="801" />
<code_context>
+ app.post(
+ '/verify/onramper/sign',
+ requestRateLimiter(20, 1),
+ passport.authenticate(['jwt', 'anonymous'], { session: false }),
+ wrapAsync(async (req, res) => {
+ const { log, body = {} } = req
</code_context>
<issue_to_address>
**🚨 issue (security):** Allowing the `anonymous` strategy here turns this into a public signing oracle, which effectively exposes the HMAC capability to anyone.
With `passport.authenticate(['jwt', 'anonymous'])`, this endpoint will sign arbitrary `signContent` with the shared HMAC secret for unauthenticated callers, effectively exposing the signing capability and undermining the purpose of the secret.
Require a strictly authenticated strategy (e.g. `jwt` only) and/or add authorization so only trusted callers can access this endpoint; otherwise any external party can generate valid Onramper signatures as if they held the secret.
</issue_to_address>
### Comment 2
<location path="src/server/verification/__tests__/verificationAPI.js" line_range="552-558" />
<code_context>
+ })
+ })
+
+ test('POST /verify/onramper/sign returns 400 for missing signContent', async () => {
+ await request(server).post('/verify/onramper/sign').send({}).expect(400, {
+ ok: -1,
+ error: 'missing signContent'
+ })
+ })
+
</code_context>
<issue_to_address>
**suggestion (testing):** Add a test case for non-string `signContent` to cover the type check branch.
The case where `signContent` is present but not a string (`typeof signContent !== 'string'`) isn’t currently tested. Please add a test (e.g. `send({ signContent: { foo: 'bar' } })` or a number/array) and assert it returns the same 400 response, so the type guard branch is covered and protected against regressions.
```suggestion
test('POST /verify/onramper/sign returns 400 for missing signContent', async () => {
await request(server).post('/verify/onramper/sign').send({}).expect(400, {
ok: -1,
error: 'missing signContent'
})
})
test('POST /verify/onramper/sign returns 400 for non-string signContent', async () => {
await request(server).post('/verify/onramper/sign').send({
signContent: { foo: 'bar' }
}).expect(400, {
ok: -1,
error: 'missing signContent'
})
})
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
sirpy
requested changes
Mar 1, 2026
…est for invalid signContent
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Adding endpoing to Sign url content for onramper flow.
Summary by Sourcery
Add an endpoint to sign Onramper URL content using a configurable secret and expose it through the verification API.
New Features:
Tests: