Skip to content

fix(security): JS isolation parent decode budget, RegExp symbol methods budget, single-use TOTP codes - #749

Merged
fclairamb merged 16 commits into
mainfrom
security/scan-specs-2026-11-03
Nov 3, 2026
Merged

fclairamb merged 16 commits into
mainfrom
security/scan-specs-2026-11-03

Conversation

@fclairamb

@fclairamb fclairamb commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Implements the three specs filed from the daily security scans of 2026-11-03.

What changed

  • AD1 (medium): the parent of a JS check's child process now bounds what it decodes. The child encodes arguments with the JSON.stringify captured before the script runs. The parent caps binding arguments (8 MiB) and results (4 MiB), plus 131072 JSON values, before building any object. A refusal ends the run as error and names the limit.
  • AD2 (low; medium with SP_JS_ISOLATION=off): RegExp.prototype[Symbol.replace] and [Symbol.split] called directly are charged to the memory budget like their String.prototype twins. A global match costs 32 bytes per match.
  • AD3 (low): a TOTP code works once in Verify2FA, Disable2FA and Confirm2FA (atomic compare-and-set on the last matched step, new db.Service.RaiseGlobalCounter). A refused replay counts as a failed attempt. Turning 2FA off sends a notice email (en, fr, de, es).
  • Batch gate: the notifications test mock gained RaiseGlobalCounter.

Behaviour changes: a JS output over 4 MiB or 131072 values now ends as error; a code just used to sign in or enable 2FA can't be reused within ~90 s.

Decided by autopilot

  • AD3, reuse the 2FA attempt budget for refused replays: yes, a replay counts as a failed attempt (recommended answer).

Note

Two wall-clock assertions in checkjs/memory_test.go (TestMemoryBudgetRefusesHeavyCopies, TestMemoryBudgetChargesRegexpSymbolMethods) failed once when the whole suite ran in parallel on a loaded machine, and pass alone and on re-run. Watch them in CI.

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

AC2–AC7, AB1–AB4, AA1–AA2, Z1–Z2, Y1, X1–X4, V1, W1, U1, S1, R1, Q1, P1, K1: see their specs in specs/done/.

fclairamb and others added 7 commits November 3, 2026 07:23
A binding call's arguments and the script's result, as the child sends
them, are checked before the parent builds anything from them: 8 MiB for
the arguments, 4 MiB for the result, and 131,072 JSON values for each
(counted in one string-aware scan of the structural tokens). Past a limit
the run ends as an error naming it. The child encodes arguments with the
capped JSON.stringify captured before the script runs, so replacing
JSON.stringify no longer hands the parent free text. A run refused this
way is no longer reported as an out-of-memory kill.

Spec: specs/todos/2026-11-03-01-js-isolation-parent-decode-budget.md

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… memory budget

RegExp.prototype[Symbol.replace] and [Symbol.split] now charge their output
like String.prototype.replace and split, which reach them for a regexp and
now leave the charging to them. A global match is charged 32 bytes per match
as exec finds it. A direct re[Symbol.replace](s, "$'") call no longer grows
the worker's heap to tens of GB with SP_JS_ISOLATION=off.

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

codecov Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.49587% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.19%. Comparing base (e3c2416) to head (9f43c80).

Files with missing lines Patch % Lines
server/internal/checkers/checkjs/isolation_wire.go 82.00% 9 Missing ⚠️
server/internal/checkers/checkjs/memory_strings.go 85.10% 7 Missing ⚠️
server/internal/db/postgres/postgres.go 90.24% 4 Missing ⚠️
...erver/internal/checkers/checkjs/isolation_child.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #749      +/-   ##
==========================================
+ Coverage   88.92%   89.19%   +0.26%     
==========================================
  Files        1317     1318       +1     
  Lines      134677   134873     +196     
==========================================
+ Hits       119767   120305     +538     
+ Misses      14901    14559     -342     
  Partials        9        9              
Files with missing lines Coverage Δ
server/internal/checkers/checkjs/isolation.go 75.36% <100.00%> (+1.47%) ⬆️
server/internal/checkers/checkjs/memory.go 42.29% <ø> (+17.35%) ⬆️
...erver/internal/checkers/checkjs/regexp_deadline.go 58.71% <100.00%> (+50.50%) ⬆️
server/internal/db/dblock/dblock.go 86.48% <ø> (ø)
server/internal/db/sqlite/sqlite.go 96.72% <100.00%> (+0.03%) ⬆️
server/internal/email/supportreply.go 92.68% <ø> (ø)
server/internal/handlers/auth/service.go 90.00% <100.00%> (-0.10%) ⬇️
server/internal/handlers/auth/totp_replay.go 100.00% <100.00%> (ø)
server/internal/handlers/emailpreview/fixtures.go 100.00% <ø> (ø)
...internal/handlers/emailpreview/fixtures_account.go 100.00% <100.00%> (ø)
... and 4 more

... and 30 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 8 commits November 3, 2026 07:46
…ed off

Verify2FA, Disable2FA and Confirm2FA now record the time step of the
last accepted code (state entry totp_last_step:<user>:<secret hash>,
5 min TTL) through a new atomic RaiseGlobalCounter, and refuse a code
at or before it with the same error as a wrong code. A refused replay
spends the shared 2FA attempt budget. Disable2FA sends a new
totp-disabled notice email (en, fr, de, es).

Behaviour change: the code used to sign in or to confirm 2FA can no
longer be reused right after; the next code must be used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rm 2FA enrollment with the previous TOTP step in e2e

The replace suffix/prefix refusals do 200000 matches of permitted work first, so a fixed 1s bound flaked on slow runners. The e2e tests confirmed enrollment and signed in with the same TOTP code, which the single-use rule now refuses.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@fclairamb
fclairamb merged commit d55abe5 into main Nov 3, 2026
34 checks passed
@fclairamb
fclairamb deleted the security/scan-specs-2026-11-03 branch November 3, 2026 13:02
@fclairamb fclairamb mentioned this pull request Nov 3, 2026
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