Skip to content

[codex] programs: sandbox CLI with Landlock on Linux - #4745

Open
maxvanamersfort wants to merge 1 commit into
facebook:devfrom
maxvanamersfort:harden-landlock-cli
Open

[codex] programs: sandbox CLI with Landlock on Linux#4745
maxvanamersfort wants to merge 1 commit into
facebook:devfrom
maxvanamersfort:harden-landlock-cli

Conversation

@maxvanamersfort

Copy link
Copy Markdown

Summary

  • add best-effort Landlock confinement to the Linux zstd CLI
  • restrict filesystem writes to the selected output locations and source parents required by --rm
  • deny unneeded filesystem operations, network access, external signals, and abstract Unix sockets when supported by the running Landlock ABI
  • add a regression test that verifies allowed output and rejects writes, truncation, deletion, FIFO creation, symlink creation, and directory removal outside the intended policy

Addresses #3637.

Motivation

The CLI processes attacker-controlled compressed input in a process that normally retains all of the invoking user's filesystem and network privileges. Landlock can reduce the impact of a parser or codec vulnerability without requiring privileges or a separate sandbox launcher.

The policy deliberately leaves reads unrestricted so existing dictionary and input-file workflows keep working. Writes are permitted only where the selected command needs them. On newer Landlock ABIs, network and process-scoping features are also handled without granting them.

Compatibility

  • uses the syscall ABI directly so builds do not depend on recent Landlock headers
  • continues normally when the kernel or execution environment does not expose Landlock
  • treats unexpected setup failures as fatal instead of silently running with a partially configured policy
  • detects WSL DrvFS/9p and opts out because its nested-path Landlock behavior can reject valid output
  • keeps non-Linux builds on a no-op implementation

Validation

  • built the normal Linux zstd target with warnings treated as errors
  • built all seven supported CLI variants with warnings treated as errors
  • passed the complete upstream CLI suite: 44 of 44 tests
  • passed the new Landlock negative regression test
  • exercised compression, decompression, --rm, list, test, dictionary training, explicit output, /dev/null, and mirrored-output workflows
  • traced the CLI to verify that Landlock is installed before operation-specific input processing and inherited by worker threads

@meta-cla

meta-cla Bot commented Aug 27, 2026

Copy link
Copy Markdown

Hi @maxvanamersfort!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed label Aug 27, 2026
@meta-cla

meta-cla Bot commented Aug 27, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@maxvanamersfort
maxvanamersfort marked this pull request as ready for review August 27, 2026 10:19
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