This repository was archived by the owner on Apr 14, 2026. It is now read-only.
feat: validate app_id format in verify API - #389
Open
odaysec wants to merge 1 commit into
Open
Conversation
Added validation for app_id format in verify API.
|
@odaysec is attempting to deploy a commit to the Worldcoin Team on Vercel. A member of the Team first needs to authorize it. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Added validation for app_id format in verify API. do not use
app_idfrom the HTTP request body directly in the verification URL. Instead, validate and normalize it at the API boundary so it matches an expected pattern (for example,app_followed by alphanumerics, dashes, or underscores), and reject or sanitize any value that does not conform. Ensure that theendpointoverride is not user-controlled in the example path (it currently isn’t), and keep the hostname fixed.Best concrete fix with minimal behavior change:
examples/with-next/pages/api/verify.ts, validateapp_idfromreq.bodyagainst a strict regular expression that enforces the knownapp_...format. If the value is invalid, return an error response instead of callingverifyCloudProof.app_idintoverifyCloudProofso the rest of the flow remains unchanged.verifyCloudProofalready typesapp_idas`app_${string}`, we don’t modify that function’s signature or internals; we only ensure that what we pass in satisfies the expected constraints.All changes are confined to
examples/with-next/pages/api/verify.ts;packages/core/src/lib/backend.tsremains unchanged from the snippet, because onceapp_idis validated, the URL construction is safe and remains functionally identical for valid inputs.Concretely:
{ proof, app_id, action, signal }inhandler./^app_[A-Za-z0-9_-]+$/to constrain allowedapp_idvalues.