Skip to content

docs(ses): document Compartment availability and OOM limits (#2742)#68

Open
kriscendobot wants to merge 5 commits into
masterfrom
design/issue-2742-compartment-limits-doc
Open

docs(ses): document Compartment availability and OOM limits (#2742)#68
kriscendobot wants to merge 5 commits into
masterfrom
design/issue-2742-compartment-limits-doc

Conversation

@kriscendobot

Copy link
Copy Markdown
Collaborator

Summary

Implements endojs/endo#2742 by documenting two threats a Compartment cannot mitigate, both intrinsic to running JavaScript in a single agent.

  • Adds a top-level Limitations section to docs/lockdown.md with two subsections:
    • Availability — A guest in an infinite loop, runaway recursion, or any non-terminating synchronous computation denies synchronous progress to every sibling compartment and the start compartment, until the engine intervenes.
    • Memory exhaustion — Because the JS spec does not require an engine to abort the agent on OOM (see the TC39 OOM-fails-fast proposal), a malicious compartment can intentionally exhaust memory; the resulting failure may surface inside an unrelated synchronous call into a victim's exported object, turning an availability concern into an integrity one.
  • Cross-links the new section from packages/ses/README.md's ### Compartment section so readers find it where Compartment is introduced.

Both items are phrased as "what a Compartment cannot protect against" rather than as a critique — they are intrinsic to sharing one JavaScript agent.

New section preview

Limitations

Compartments isolate the authority and intrinsics available to guest code, but every compartment in a realm shares the same JavaScript agent — in engine terms, a single thread of execution and a single heap.

Anchor used for the cross-link: ./docs/lockdown.md#limitations (verified by building yarn docs and inspecting the generated api-docs/documents/lockdown.html).

Test plan

  • npx prettier --check docs/lockdown.md packages/ses/README.md — clean
  • yarn docs — typedoc still builds; new #limitations anchor is generated
  • Render markdown in a viewer to confirm internal links resolve

@kriskowal kriskowal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally avoid em-dashes. Please integrate that feedback into CLAUDE.md in the style guide.

Comment thread docs/lockdown.md Outdated
Comment on lines +1225 to +1226
but every compartment in a realm shares the same JavaScript *agent* — in
engine terms, a single thread of execution and a single heap.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate sentences in this case. The em-dash is not more clear.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 5995742: split the agent-introduction sentence so the en-dash is gone and the second clause stands on its own ("...shares the same JavaScript agent. In engine terms, that is a single thread of execution and a single heap.").

Comment thread docs/lockdown.md Outdated
Comment on lines +1230 to +1231
as a separate worker, process, or operating-system sandbox, around the
suspect code.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
as a separate worker, process, or operating-system sandbox, around the
suspect code.
as a separate worker or process around the
suspect code.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied verbatim in 5995742.

Comment thread docs/lockdown.md Outdated
A compartment cannot protect availability for code running in sibling
compartments or in the start compartment.
Because all compartments share the agent's single thread, a guest that enters
an infinite loop, a `while (true) {}`, a runaway recursion, or any other

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider for (;;) {}, which I like to call a C’thuloop.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swapped while (true) {} for for (;;) {} in 5995742. Did not include the C'thuloop label inline (the surrounding paragraph already enumerates the failure modes by name); happy to add a parenthetical if you want the label to ship in the doc.

kriskowal and others added 2 commits May 1, 2026 01:45
Adds a "Limitations" section to docs/lockdown.md describing two threats
a Compartment cannot mitigate, both intrinsic to sharing a single
JavaScript agent: (a) availability — an infinite loop or runaway
synchronous computation in any compartment denies progress to all
sibling compartments until the engine intervenes; and (b) memory
exhaustion — because the JS spec does not require an OOM to abort the
agent (see the TC39 OOM-fails-fast proposal), a malicious compartment
can intentionally exhaust memory and surface failures inside unrelated
synchronous calls, turning an availability concern into an integrity
one.

Cross-links the new section from packages/ses/README.md's Compartment
section so readers reach it from the place Compartment is introduced.

Refs: endojs/endo#2742

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Split the agent-introduction sentence rather than using an em-dash.
- Apply review suggestion: drop "operating-system sandbox" and reword
  the coarser-boundary clause to "as a separate worker or process
  around the suspect code."
- Replace the `while (true) {}` example with `for (;;) {}`.
- Sweep remaining em-dashes from the new Limitations section.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kriscendobot kriscendobot force-pushed the design/issue-2742-compartment-limits-doc branch from e435d96 to 5995742 Compare May 1, 2026 01:49
Per kriskowal review on #2742: em-dashes obscure technical prose
and almost always read better as separate sentences, parentheses,
or colons.  Lock the rule into AGENTS.md so future agents pick it
up without rediscovering the convention.

Also surfaces the existing "wrap 80–100 columns, sentence-per-line"
markdown rule that lived only in CONTRIBUTING.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread docs/lockdown.md
Comment on lines +1229 to +1231
A host that needs to defend against them must impose a coarser boundary,
as a separate worker or process around the
suspect code.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should dedicate a section timing side-channels. Note that the default Compartment does not include any timers of any resolution, but it is very difficult to avoid inadvertently giving a guest program the ability to measure duration. Asynchronous communication to another worker or process is often enough to inadvertently expose a confined guest to a gadget for measuring the passage of time.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the Timing side-channels section in f299f8e, placed as a third subsection under Limitations alongside Availability and Memory exhaustion. The section notes that the default Compartment excludes Date, performance.now, setTimeout, setImmediate, and other host scheduling primitives; explains that asynchronous round-trips to any other agent recover wall-clock duration; spells out the audit obligation (every async boundary the guest can reach, not just timer-like APIs in the global scope); and lists the host mitigation menu (separate worker or process; outbound rate throttling; padded guest-visible message timing).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section on timing side channels should cite https://papers.agoric.com/taxonomy-of-security-issues/

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a reference paragraph at the end of the Timing side-channels section pointing at https://papers.agoric.com/taxonomy-of-security-issues/ as the broader catalog this section samples. Pushed in the latest commit.

…742)

Document the third class of containment limit alongside Availability and
Memory exhaustion. Note that the default Compartment intentionally
omits Date, performance.now, setTimeout, and other host scheduling
primitives, but that any asynchronous boundary the guest can drive is
also a potential timing source: the round-trip recovers wall-clock
duration. Spell out the audit obligation (every async boundary, not
just timer enumeration) and the host's mitigation menu (separate
worker or process; outbound rate throttling; padded message timing).

Addresses kriskowal review 4233409679.
@kriscendobot

Copy link
Copy Markdown
Collaborator Author

Addressed both reviews; ready for another look.

Review 4209498509 (already in tree at 5995742):

  • Em-dash split on docs/lockdown.md:1226 -> two sentences.
  • Suggestion application at docs/lockdown.md:1231 -> applied verbatim.
  • while (true) {} -> for (;;) {} at docs/lockdown.md:1238.

Review 4233409679 (new in f299f8e):

  • Added a third subsection under Limitations: Timing side-channels.
    Notes that the default Compartment excludes Date, performance.now,
    setTimeout, setImmediate, and other host scheduling primitives;
    explains that asynchronous round-trips to any other agent recover
    wall-clock duration; states the audit obligation (every async boundary,
    not just timer enumeration); and lists the host mitigation menu
    (separate worker or process; outbound rate throttling; padded
    guest-visible message timing).

Thread replies posted on each of the four inline comments citing the
addressing SHA. Re-requesting review.

@kriscendobot kriscendobot requested a review from kriskowal May 8, 2026 19:05
kriscendobot pushed a commit that referenced this pull request May 10, 2026
…er B sweep

Builder B's 2026-05-10 sweep found 4 of 7 queue items already covered
by existing OPEN/MERGED PRs (#67/#64/#68 open, #66 closed because
#2749 merged upstream as #3227), plus 2 with misclassified plans
(#922 names a package not in this repo; #1298 is per-file investigation,
not mechanical mop-up). Net 1 new PR (#182 for #947). Updated AGENT-READY
to surface PR numbers for each in-flight item and reframe the impasses.
@erights erights self-requested a review May 12, 2026 22:49
@kriskowal

Copy link
Copy Markdown
Member

Ferried upstream as endojs/endo#3275 (head 4d8ed6be74c861472a85df3f38af7081f1d6689c).

The upstream PR squashes 4 of the 5 commits on this branch (8a1fc626, 59957425, f299f8e4, 838d18ff) into one. Commit cb8d6286 (the AGENTS.md prose-style rule) is explicitly excluded as off-topic for issue #2742; a separate ferry can carry it later if desired. The upstream commit message adds Fixes #2742.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants