Skip to content

id(world_compile): check_imports matches the literal 'import ' prefix — a double space or tab imports an ungranted platform module #2095

Closed

Description

@dezren39

Summary

check_imports in pkgs/id/src/world_compile.rs — the only gate that keeps a compile request from importing platform modules the world was not granted — matches imports with the literal prefix "import " (exactly one ASCII space). Roc's parser accepts other whitespace between import and the module path, so an ungranted import written with two spaces or a tab passes the gate and compiles.

Evidence (verified this run, main bd880194; world_compile.rs sha256 11b5c8afaecdb8ddcd23e796cc588908b9cc39506485c87d8961617cecc0d583)

The gate, world_compile.rs:118-144:

  • :121 — line.trim_start().strip_prefix("import "): a tab after import makes the prefix miss, so the line is skipped entirely.
  • :124-127 — with two spaces, rest starts with a space and split(whitespace | '[' | '{' | '(').next() yields the empty string, so the path examined is "" and no segment is ever checked.

compile() stages the whole platform (copy_platform, world_compile.rs:~227), so every platform module is resolvable by the compiler; this line scan is the sole grant enforcement before the compiler runs.

Verbatim-logic probe (laptop, ~/git/fleet/probe-2026-10-28-laneB-importws/probe_import.rs, modules [Key, Screen], granted []):

  • import pf.Screen → refused: "main.roc imports Screen, which this world does not allow" (control)
  • import pf.Screen (two spaces) → Ok
  • import<TAB>pf.Screen → Ok
  • leading-tab + single space, and import pf.Screen exposing [x] → refused (those paths work)
  • sibling file Helper.roc with import pf.Key → Ok (the sibling-smuggle test at world_compile.rs:1281 only covers the single-space form)

Roc acceptance probe (laptop roc fmt, same probe dir): both the double-space and tab forms parse and are normalized by the formatter to import pf.Screen (exit 0). Checked and NOT a bypass: import pf . Screen passes the gate but Roc rejects it (incomplete_import parse error), so spaced dots are out of scope.

Why it matters

Platform modules are the world's capabilities (Screen, Key, …). The grant list is the effective intersection of world grants with server/world ceilings (see compile() docs, world_compile.rs:188-204). A world author who was granted nothing — or whose ceiling excludes a module — can use it anyway by changing one space to two, silently defeating the ceiling the operator configured. The existing tests (an_ungranted_platform_import_is_refused_by_name, a_sibling_file_cannot_smuggle_an_ungranted_import) pin only the canonical single-space spelling.

Acceptance criteria

  • check_imports recognizes an import regardless of the whitespace Roc accepts between import and the path (at minimum: multiple spaces, a tab), in main.roc and in sibling files.
  • Regression tests: the double-space and tab spellings of an ungranted platform import are refused by name, mirroring the existing single-space tests; the granted and * cases still pass for those spellings.
  • No false refusals: comment lines (# import pf.Screen), non-platform imports, and exposing [...] forms keep their current behavior.
  • Token-based parsing (first token import, second token the path) or an equivalent whitespace-flexible scan is fine; matching Roc's exact grammar is not required beyond the whitespace class.

Activity

  1. developing-today commented on Oct 29, 2026

    @developing-today
    Contributor
  2. added
    kind/securitySecurity issue or security hardening
    priority/normalOrdinary priority (the default)
    queue/queuedHas a queued task in the Supabase agent queue
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/xsTrivial: expected under 30 minutes of work
    on Oct 29, 2026
  3. dezren39 commented on Oct 29, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator-code-b
    • Session / ID: new-issue-creator-code-b run 2026-10-29T02:56Z
    • Found via: filed this run
    • Task: Triage the check_imports whitespace bypass: the capability gate matches the literal 'import ' prefix, so a double-space or tab spelling imports an ungranted platform module.
    • Expectation: effort/xs — done when check_imports sees every whitespace spelling Roc accepts (multiple spaces, tab), in main and sibling files, with regression tests mirroring the single-space ones and no false refusals on comments/non-platform imports.
    • Links: evidence in issue body; probe ~/git/fleet/probe-2026-10-28-laneB-importws/ (laptop: verbatim checker probe + roc fmt acceptance)
  4. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 1, 2026
  5. 31 remaining items

  6. added
    status/parkedDeliberately paused with a recorded resume condition
    on Nov 1, 2026
  7. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked

    • Agent: openchamber-scheduled-lane (repo-worker-code)
    • Session / ID: ses_e5e69f2f2f7ffeJTf9xOmPiRUc · queue task 5183
    • Task: PR fix(id): whitespace-flexible import scan in check_imports (#2095) #3392 remains open at a5ec5fe. Started cargo test --lib world_compile in /home/user/git/fleet/5183/pkgs/id; result is not yet verified.
    • Resume: Check output at /home/user/.local/share/opencode/shell/7c77335d64f274eda14617ff1d9e59c351817dd6/sh_1a1960e8b0b001j6iP3XMFp9tC.out, then review PR and checks before merging. Parked 20 minutes.
  8. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up (resume)

    • Agent: repo queue worker, lane D (repo-queue-worker-shift-d)
    • Session / ID: queue task 5183 (small_fix), re-claimed 2026-11-01T08:05Z
    • Task: Resume from the parked state: PR fix(id): whitespace-flexible import scan in check_imports (#2095) #3392 (branch queue/5183-2095-check-imports-whitespace, head a5ec5fe) already carries the pinned token-based check_imports fix + both regression tests. Lane A's 07:10Z note records the blocker: the targeted laptop test run hit a 1500s cap while compiling under fleet contention — no test executed, no pass claimed.
    • Expectation: obtain the targeted world_compile test evidence (full output captured to a file on the laptop), then merge PR fix(id): whitespace-flexible import scan in check_imports (#2095) #3392 if green and close this issue. Codex review on the current head is already complete with zero findings.
  9. added a commit that references this issue on Nov 1, 2026
  10. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done — PR #3392 merged

    • Agent: repo queue worker, lane D (repo-queue-worker-shift-d)
    • Session / ID: queue task 5183 (small_fix), resumed and completed 2026-11-01
    • Result: PR fix(id): whitespace-flexible import scan in check_imports (#2095) #3392 merged as 75a1713 (verified as main HEAD, parents include the PR head a5ec5fe). check_imports now recognizes imports token-wise (any whitespace run between import and the path), closing the double-space/tab bypass of the platform grant gate.
    • Verification: targeted laptop run, full output captured to a file and read back (~/git/fleet/5183/test-5183.log): cargo test --lib world_compile — 27 passed, 0 failed, exit 0, including both new regression tests by name (an_ungranted_platform_import_with_extra_whitespace_is_refused_by_name; a_sibling_file_cannot_smuggle_an_ungranted_import_with_extra_whitespace) and all pre-existing gate tests. Codex review on a5ec5fe: completed, zero findings. This repo runs no PR CI (commit status pending with zero statuses), per the standing pattern.
    • Credit: the fix and tests were authored in this task's earlier claim (lane A / openchamber lane); this shift resumed it past the laptop-contention blocker, verified, and landed it.
  11. removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/securitySecurity issue or security hardeningpriority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions