Repository navigation
fix: block proc mem executable page writes - #241
Conversation
## Problem Linux mounted workload procfs writable. A workload could open /proc/*/mem and write to an executable page. That bypassed the executable-memory syscall filter. ## Solution Mount workload procfs read-only. Add a Linux regression that tries each reachable /proc/*/mem route against a read-execute page. The test keeps direct memory writes and plain writable mappings as controls. ## Tests cargo fmt --check passed. git diff --check passed. cargo test -p strands-box-containment passed. cargo clippy -p strands-box-containment --all-targets exited 0 with existing macOS unused-code warnings. The mutation that made /proc writable again failed proc_mem_cannot_write_executable_memory with code 61.
|
Assessment: Request Changes This review covers head Checks that held
The fix is small and targeted, and the mutation check against a writable |
|
Assessment: Approve This re-review covers head Checks that held
The fix is small and well pinned. |
Human readable section
Problem. A Linux workload inside Box could change memory containing executable code through
/proc, Linux's filesystem for process information and controls. This bypassed Box's existing restrictions on system calls that change executable memory.Solution. Box now mounts the workload's
/procfilesystem read-only. The workload can still read permitted process information, but it cannot open process-memory files for writing.Trade-off. This also blocks writes to other
/proccontrols. Programs cannot write the files used to assign user and group identities inside nested namespaces. These are isolated environments created within the workload. Box still permits namespace creation, but this change limits how programs can configure those environments.Description
Linux previously mounted the workload's
/procfilesystem as writable. A workload could open/proc/*/memfor writing and change an executable memory page.The regression test applies containment, the restrictions Box places on a workload. It then attempts to change a memory page that permits reading and execution but not writing. It checks these process-memory routes:
/proc/self/mem/proc/thread-self/mem/proc/<pid>/mem/proc/self/task/<tid>/mem/proc/self/root/proc/self/mem/proc/self/fd/<fd>for a read-only/proc/self/memdescriptorIn these paths,
<pid>means process ID,<tid>means thread ID, and<fd>means an open file descriptor number. A file descriptor is a handle a process uses to access an open file or communication channel.The file-descriptor case first opens the process-memory file for reading. It then tries to reopen that same file for writing through
/proc/self/fd/<fd>. The test requires the initial read-only open to succeed, so a setup failure cannot count as successful protection. The test also checks a direct memory assignment and a plain writable anonymous mapping, which allocates memory without a backing file.This change preserves the existing executable-memory restriction. It does not add support for just-in-time code generation, where a program creates executable code while running. It does not establish isolation of the supervisor, the Box process that manages the workload, or validate cloud deployment targets.
Related Issues
Related security finding: Robosec finding
Related compatibility discussion: Issue #42
Type of Change
Bug fix
Testing
Hosted checks at
c5641a0. GitHub's CI Gate passed. This continuous integration result is separate from the local evidence below. It does not establish complete test coverage or human approval.Local test evidence
The local test revision is not recorded in this description. These results report tests on 64-bit Arm (ARM64) Linux, kernel
6.12.113-138.209.amzn2023.aarch64. Build and test concurrency were limited to two jobs.cargo build -p strands-box-containment --all-featurescargo test -p strands-box-containment --all-features --no-fail-fast -- --nocapturecargo clippy -p strands-box-containment --all-targets --all-featurescargo fmt -p strands-box-containment --checkgit diff --checkcargo build -p strands-box-containment --no-default-featuresbash scripts/test-all.sh box-examplesEXPERIMENTAL_LINUX_SUPPORT=TRUE bash test-integ/run.sh/proc/procmutationThe two mutation checks deliberately removed a protection or broke setup and confirmed that the test failed. Both temporary mutations were restored before the full package gates ran. The integration run used the freshly built Box binaries. An initial run stopped at the Linux opt-in check; the corrected run used the setting from continuous integration. These checks cover the Linux host. Full workspace, native macOS, Runtime, Lambda MicroVM, and cloud qualification tests were not run locally for this follow-up.
Checklist
/procrestriction and its nested identity-mapping limitation.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.