Skip to content

fix(security): JS check memory budget gaps and regexp time limit, Discord link re-authentication, invitation cap - #735

Merged
fclairamb merged 25 commits into
mainfrom
security/scan-specs-2026-11-01
Nov 1, 2026
Merged

fclairamb merged 25 commits into
mainfrom
security/scan-specs-2026-11-01

Conversation

@fclairamb

@fclairamb fclairamb commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

No description provided.

fclairamb and others added 4 commits November 1, 2026 07:31
…e flattening against the memory budget

Closes the four paths of security finding AB1 (spec 2026-11-01-01):
- typed arrays built from an array-like read its length once (pinned
  behind a Proxy), so a length getter can no longer answer 0 to the charge
  and a huge value to the allocation;
- concat, slice, splice and filter are charged for their result; flat and
  flatMap are rewritten in Go and charge each element before appending it;
- String.prototype.split is charged per part, replace/replaceAll for their
  output (the replacement goes to goja as a Go function that measures and
  charges each expansion, or is charged up front for a string pattern);
- Function.prototype.apply, Reflect.apply and Reflect.construct check an
  array-like argument list;
- stopgap for the + rope: a rope over 64 KiB is charged when a
  String.prototype or RegExp method, a binding (arguments scanned deeply)
  or the result export would flatten it. Other flatten paths (s[0], ==,
  Number(s)) still need process isolation, a follow-up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.14660% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.79%. Comparing base (f44707a) to head (689eb11).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
server/internal/checkers/checkjs/memory_strings.go 91.21% 21 Missing ⚠️
server/internal/checkers/checkjs/memory.go 93.52% 9 Missing ⚠️
...erver/internal/checkers/checkjs/memory_bindings.go 90.00% 6 Missing ⚠️
server/internal/handlers/auth/service.go 93.02% 3 Missing ⚠️
...rver/internal/handlers/auth/discord_link_notice.go 86.66% 2 Missing ⚠️
server/internal/handlers/auth/handler.go 33.33% 2 Missing ⚠️
server/internal/handlers/auth/personal_org.go 90.00% 1 Missing ⚠️
...er/internal/handlers/auth/registration_ip_limit.go 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #735      +/-   ##
==========================================
+ Coverage   89.77%   89.79%   +0.02%     
==========================================
  Files        1306     1310       +4     
  Lines      132987   133514     +527     
==========================================
+ Hits       119389   119891     +502     
- Misses      13589    13614      +25     
  Partials        9        9              
Files with missing lines Coverage Δ
server/internal/app/server.go 92.03% <100.00%> (+<0.01%) ⬆️
server/internal/checkers/checkjs/checker.go 92.20% <100.00%> (+0.36%) ⬆️
server/internal/checkers/checkjs/regexp.go 100.00% <100.00%> (ø)
server/internal/email/supportreply.go 92.68% <ø> (ø)
server/internal/entitlements/service.go 93.28% <100.00%> (+0.09%) ⬆️
server/internal/handlers/auth/discord_link.go 83.33% <100.00%> (+0.72%) ⬆️
server/internal/handlers/auth/factor_reauth.go 89.53% <100.00%> (+0.12%) ⬆️
server/internal/handlers/auth/passkey_handler.go 94.69% <100.00%> (ø)
server/internal/handlers/auth/passkey_notice.go 100.00% <100.00%> (ø)
server/internal/handlers/base/base.go 96.49% <ø> (ø)
... and 13 more

... and 22 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

fclairamb and others added 20 commits November 1, 2026 07:49
goja runs patterns with lookarounds or backreferences on regexp2, whose
default match timeout is forever, and vm.Interrupt cannot reach a running
match. A nested quantifier on a non-matching input pinned a core per run.
regexp2.DefaultMatchTimeout is now 2 s process-wide; a timed-out match is
reported as ERROR "regular expression took too long" without echoing the input.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l the owner

link-start now asks for the current password (or a recent sign-in for a
passwordless account), like a new TOTP or passkey, and a successful link
enqueues a discord-linked.html security notice (en, fr, de, es).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uthentication and sends no notice

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uthentication and sends no notice

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…h keyed lookups

Invitations: 50 live per org (or the seat cap when lower), 409 TOO_MANY_INVITATIONS.
Sign-in finds pending invitations through invite_email:<hash>:<org>.
Registrations: per-IP slots and token lookup are keyed (registration_ip:, registration_token:).
Invitations and registrations pending before the upgrade have no new keys: invitees use their link, sign-ups re-submit.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…tions of the instance, and outstanding invitations are uncapped

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…tions of the instance, and outstanding invitations are uncapped

Cap test asserts no email job on refusal (with positive control) and uses a real past expires_at. Migration decision (no fallback) recorded in the spec.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
They copy up to the whole budget before being refused (0.3-0.5s of CPU), so
among ~50 parallel subtests on a loaded runner they hit the 2s script timeout
and the 1s bound. Assertions unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ot a fixed second

The refusal is exact and comes before the refused allocation, but goja has
really copied what the budget still allowed (up to ~2M slots) by then, which
took 1.7s on a loaded runner. Time the permitted part of each script as a
baseline and require the refusal within 3x of it plus a margin.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The test revoked list.Data[0], which is ordered by random token hash, so
about 1 run in 50 it revoked invites[1] (the one it then expires), leaving
the org at the cap.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@fclairamb
fclairamb enabled auto-merge (squash) November 1, 2026 14:49
@fclairamb
fclairamb merged commit 6026b05 into main Nov 1, 2026
32 checks passed
@fclairamb
fclairamb deleted the security/scan-specs-2026-11-01 branch November 1, 2026 15:07
fclairamb added a commit that referenced this pull request Nov 2, 2026
… process isolation, crawl link scheme, subscriber list role, reset links on password change (#742)

Specs filed from the daily security scans. Each spec is the tracker for
its finding.

## What changed (specs implemented by this PR)

- **AC2 (medium)**:
`specs/todos/2026-11-02-01-js-checker-memory-budget-residuals.md`. Even
after #735, one native call in a JS check can allocate GBs:
`JSON.stringify`, `toLocaleString`, `normalize`, `String.raw`, the URI
encoders, and ropes flattened by `JSON.parse`, by a thrown error (which
also stores a huge error string with the result) or hidden deeper than
the scan's depth cap. Now charged, with the rest of the amplifying
builtins; the thrown error text is capped at 16 KiB. Process isolation
is filed as AC7.
- **AC3 (medium)**:
`specs/todos/2026-11-02-02-js-checker-regexp-total-time.md`. The 2 s
regexp limit of #735 applies to each match. A global `replace` chains
slow matches into hours of CPU in one call that the timeout cannot stop.
Now bounded for the whole run.
- **AC4 (low)**:
`specs/todos/2026-11-02-03-crawl-finding-url-scheme.md`. Sitemap URLs
from `robots.txt` and sitemap indexes skip the http(s) filter, so a
crawled site can plant a `javascript:` link in a check's findings. The
dashboard CSP blocks it today. Now filtered in the crawler, and dash0
renders only http(s) links.
- **AC5 (low)**:
`specs/todos/2026-11-02-04-status-page-subscribers-admin-only.md`.
Viewers can list a status page's subscriber email addresses. The list is
now admin-only (breaking for viewer/user API clients).
- **AC6 (low)**:
`specs/todos/2026-11-02-05-password-reset-tokens-purged-on-change.md`.
Outstanding password-reset links survive a password change, a reset and
an email change. Reset links are now deleted on each of these.

- **AC7 (medium)**:
`specs/todos/2026-11-02-06-js-checker-process-isolation.md`. Each JS
script now runs in a memory-limited child process of the same binary
(heap watchdog, `RLIMIT_AS`, optional cgroup, kill at timeout); bindings
stay served by the parent. A killed child gives an `error`/`timeout`
result, the parent never crashes. `SP_JS_ISOLATION=off`,
`SP_JS_MEMORY_LIMIT_MB`, `SP_JS_CGROUP` documented. About 11-27 ms
overhead per run on macOS.

## Decided by autopilot

- AC5 (subscribers admin only), open question "should `user` members
keep the list?": no, admin only (recommended answer).

## Earlier scan specs (implemented, in `specs/done/2026/10/` and
`specs/done/2026/11/`)

- **AB1 (medium)**: `2026-11-01-01-js-checker-memory-budget-gaps.md`.
The JS memory budget missed ropes, dense-array copies, `split`,
`replace` and typed arrays. Fixed in #735; AC2 covers what is left.
- **AB2 (medium)**: `2026-11-01-02-js-checker-regexp-timeout.md`. A
backtracking JS regexp had no time limit. Fixed in #735 with a per-match
limit; AC3 bounds a whole call.
- **AB3 (low)**: `2026-11-01-03-discord-link-reauth.md`. Linking Discord
needed no re-authentication. Fixed in #735.
- **AB4 (low)**: `2026-11-01-04-invitation-cap-and-keyed-lookups.md`.
Uncapped invitations and instance-wide invitation scans at sign-in.
Fixed in #735.
- **AA1 (medium)**: `2026-10-31-01-js-checker-memory-budget.md`. A JS
check had no memory budget: one native builtin call could OOM-kill a
shared worker. Fixed in #728; AB1 closes its residuals.
- **AA2 (low)**: `2026-10-31-02-sign-in-factor-enrollment-reauth.md`.
Turning on TOTP and registering a passkey needed no re-authentication.
Fixed in #728; AB3 covers the Discord link.
- **Z1 (low)**:
`2026-10-30-02-bug-report-authenticated-org-membership.md`. Signed-in
non-members skipped the bug-report screenshot budget. Fixed in #715.
- **Z2 (low)**:
`2026-10-30-03-report-retention-spares-crawl-reports.md`. The report
retention sweep also deleted website crawl reports. Fixed in #715.
- **Y1 (low)**: `2026-10-29-01-bug-report-upload-instance-budget.md`.
Anonymous bug-report screenshots were capped per org, not per instance,
and never deleted. Fixed in #708; Z1 and Z2 are follow-ups.
- **X1 (high)**:
`2026-10-28-01-pat-cannot-mint-sessions-or-sign-in-factors.md`. A PAT
could open sessions in its owner's other orgs and add sign-in factors.
Fixed in #699.
- **X2 (medium)**:
`2026-10-28-02-status-subscribe-throttle-and-keep-confirmed.md`.
Unthrottled subscribe confirm emails, and re-subscribing un-confirmed a
subscriber. Fixed in #699.
- **X3 (medium on SaaS)**:
`2026-10-28-03-invite-lookup-without-org-scan.md`. Invite lookup scanned
every org. Fixed in #699.
- **X4 (low)**: `2026-10-28-04-snmp-community-secret-field.md`. The SNMP
community was not a secret field. Fixed in #699.
- **V1 (medium)**: `2026-10-27-01-device-consent-phishing-guard.md`.
Device-flow consent phishing. Fixed in #693.
- **W1 (low)**: `2026-10-27-02-disable-2fa-attempt-throttle.md`. `DELETE
/auth/2fa` had no attempt budget. Fixed in #693.
- **U1 (low)**:
`2026-10-26-02-ai-repair-hold-skips-param-only-secrets.md`. The `repair:
auto` hold applied only when the check's `secrets` map had a value.
Fixed in #683.
- **S1 (medium)**:
`2026-10-25-01-ai-repair-grant-dropped-by-reference-resolution.md`. The
repair grant was compared after `${…}` references were resolved. Fixed
in #678; U1 closed the remaining gap.
- **R1 (medium)**:
`2026-10-24-01-ai-repair-auto-apply-partial-runtime-host.md`. `repair:
auto` applied a candidate that kept a literal host and added one built
at runtime. Fixed in #663.
- **Q1 (medium)**:
`2026-10-23-02-ai-loop-secret-relay-through-model.md`. AI loops relayed
an encoded secret through the model.
- **P1 (medium)**:
`2026-10-22-01-ai-script-secret-host-guard-runtime.md`. AI runs with
real secrets were only host-checked by regex.
- **K1 (medium)**: `2026-10-20-01-sender-response-body-caps.md`.
Notification senders and RabbitMQ read responses uncapped.
- **J1 (medium)**: `2026-10-19-01-a2a-response-size-cap.md`. A2A
responses were read uncapped.
- **I1 (low)**: `2026-10-18-01-plugin-schema-file-ref.md`. Plugin schema
`$ref` could load local files.
- **G1/G2 (low)**: `2026-10-17-01-postgres-check-connection-config.md`.
Postgres conninfo escaping and fallback to the worker's `PG*` env.
- **F1**: `2026-10-16-15-pat-cache-revocation.md`. The PAT cache
outlived revocation.
- **E1**: `2026-10-16-14-totp-on-federated-sign-in.md`. No TOTP on
federated sign-in.
- **E2**: `2026-10-16-13-atomic-auth-attempt-counters.md`. Auth attempt
counters were not atomic.
- **H3**: `2026-10-16-12-mcp-tokens-rejected-on-rest.md`. MCP OAuth
tokens worked on REST.
- **H2**: `2026-10-16-11-slack-signature-fail-closed.md`. Slack
signature check failed open.
- **T1 / M2 (high)**: `2026-10-16-10-discovery-scans-egress-guard.md`.
Discovery scans were outside the egress policy.
- **N4**: `2026-10-16-09-js-check-nested-docker-guard.md`. A JS `docker`
sub-check bypassed the gate.
- **N3 (high)**: `2026-10-16-08-status-page-components-cross-org.md`.
Status-page components could be edited across orgs.
- **D2/D3 (high)**:
`2026-10-16-07-guard-status-subscriber-and-publication-webhooks.md`.
Subscriber and publication webhooks were not guarded.
- **C3**: `2026-10-16-06-accept-invite-existing-account.md`. Accepting
an invite logged in as an existing account.
- **C1**: `2026-10-16-05-kubeconfig-exec-and-incluster.md`. Kubeconfig
`exec` and `inCluster` were allowed.
- **N2**: `2026-10-16-04-mysql-dsn-injection.md`. MySQL DSN injection.
- **N1**: `2026-10-16-03-env-secret-reference-allowlist.md`. No
allowlist for `${env:}` references.
- **C2/H1**: `2026-10-16-02-token-purpose-separation.md`. Purpose tokens
were accepted as access tokens.
- **D1**: `2026-10-16-01-microsoft-signin-unverified-email-linking.md`.
Microsoft nOAuth email linking.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
fclairamb added a commit that referenced this pull request Nov 5, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.43.1](v0.43.0...v0.43.1)
(2026-11-05)


### Bug Fixes

* **ai:** send DeepSeek's reasoning_content back on assistant turns
([#739](#739))
([d62bfc6](d62bfc6))
* **dash0:** email-scanner filter, non-admin crash, audit incident
target ([#755](#755))
([920d231](920d231))
* **deps:** update dependency @hookform/resolvers to v7
([#736](#736))
([f44707a](f44707a))
* **deps:** update github.com/dop251/goja digest to 2413f21
([#756](#756))
([166579c](166579c))
* **deps:** update github.com/dop251/goja digest to 622d100
([#746](#746))
([f46b46c](f46b46c))
* **deps:** update github.com/dop251/goja digest to a177d21
([#747](#747))
([09b0d72](09b0d72))
* **deps:** update github.com/dop251/goja digest to a537e0c
([#754](#754))
([70ca3d6](70ca3d6))
* **deps:** update github.com/dop251/goja digest to a7bf126
([#753](#753))
([962eff3](962eff3))
* **deps:** update github.com/dop251/goja digest to cf2ff0e
([#730](#730))
([92b6c17](92b6c17))
* **deps:** update github.com/dop251/goja digest to f5d1d00
([#750](#750))
([44c6ecc](44c6ecc))
* **deps:** update go dependencies (non-major)
([#748](#748))
([e3c2416](e3c2416))
* **deps:** update go dependencies (non-major)
([#751](#751))
([146bec5](146bec5))
* **deps:** update go dependencies (non-major)
([#758](#758))
([17b0d6d](17b0d6d))
* **deps:** update module github.com/dlclark/regexp2/v2 to v2.12.0
([#737](#737))
([50fdb8d](50fdb8d))
* **deps:** update module github.com/oapi-codegen/oapi-codegen/v2 to
v2.8.2 ([#733](#733))
([672293f](672293f))
* **deps:** update module modernc.org/sqlite to v1.61.1
([#732](#732))
([02cd682](02cd682))
* **docs:** tour video under 500 KB
([#752](#752))
([1cdcce4](1cdcce4))
* **reports:** point "Open dashboard" at the organization's dashboard
([#744](#744))
([061eca0](061eca0))
* **security:** JS check memory budget gaps and regexp time limit,
Discord link re-authentication, invitation cap
([#735](#735))
([6026b05](6026b05))
* **security:** JS check memory budget residuals, regexp call time and
process isolation, crawl link scheme, subscriber list role, reset links
on password change
([#742](#742))
([de9aac0](de9aac0))
* **security:** JS isolation parent decode budget, RegExp symbol methods
budget, single-use TOTP codes
([#749](#749))
([d55abe5](d55abe5))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant