-
Notifications
You must be signed in to change notification settings - Fork 1
[Bug] Fix 2 CodeQL high alerts surfaced in v0.9.0 (redemption-code modulo bias + SDK ReDoS regex) #757
Copy link
Copy link
Closed
Labels
apiAPI design & endpointsAPI design & endpointsbugSomething isn't workingSomething isn't workingpriority:P1High. Should be done this cycle.High. Should be done this cycle.sdkTypeScript / Python client SDKsTypeScript / Python client SDKssecuritySecurity & trustSecurity & trustsize:SSmall: < ~1h, single file/concern. Size is informational.Small: < ~1h, single file/concern. Size is informational.status:donePR merged to develop-auto. Issue closed by Closes #N.PR merged to develop-auto. Issue closed by Closes #N.type:bugDefect: behavior diverges from intent/spec.Defect: behavior diverges from intent/spec.
Description
Activity
Metadata
Metadata
Assignees
Labels
apiAPI design & endpointsAPI design & endpointsbugSomething isn't workingSomething isn't workingpriority:P1High. Should be done this cycle.High. Should be done this cycle.sdkTypeScript / Python client SDKsTypeScript / Python client SDKssecuritySecurity & trustSecurity & trustsize:SSmall: < ~1h, single file/concern. Size is informational.Small: < ~1h, single file/concern. Size is informational.status:donePR merged to develop-auto. Issue closed by Closes #N.PR merged to develop-auto. Issue closed by Closes #N.type:bugDefect: behavior diverges from intent/spec.Defect: behavior diverges from intent/spec.
CodeQL flagged 3 new alerts on the v0.9.0
develop → mainpromotion (#755). Both high alerts are low practical severity, so v0.9.0 shipped with a tracked follow-up (per maintainer decision) rather than blocking the release. This issue tracks the fixes.1. High — modulo bias on crypto-random redemption codes
ornn-api/src/domains/redemption-codes/service.ts:127byte % 31introduces a ~1.5% modulo bias (256 % 31). The code comments already acknowledge this as accepted for human-shareable promo codes (not security tokens; unique index + retry loop absorbs collisions). Still, it's a real high-rated finding.Fix: use rejection sampling or
crypto.randomInt(0, REDEMPTION_CODE_ALPHABET.length)per character to remove the bias. Keep existing generation tests green.2. High — polynomial-backtracking regex in TS SDK
sdk/typescript/src/client.ts:70CodeQL flags
\/+$as polynomial ReDoS on "uncontrolled" input. In practicebaseUrlis a developer-set config value and the TS SDK is not yet published (held for v1.0). Low exposure, but worth removing the backtracking shape.Fix: drop the regex — strip trailing slashes with a non-regex loop/slice, or anchor a linear pattern. Add a unit test.
3. Medium/warning — workflow token permissions
.github/workflows/ci.yml:87— add an explicitpermissions:block (minimalcontents: read) to the CI workflow.Acceptance
randomInt).baseUrltrailing-slash strip has no backtracking regex.ci.ymldeclares an explicitpermissionsblock.Related: shipped in v0.9.0 (#753).