--- id: landlock version: "1.0.0.dev5" license: unclear license_treatment: permissive maintenance: active --- # landlock — Python interface to the Landlock Linux Security Module. License: permissive · Maintenance: active · Downloads: 1.7M/mo ## What it is and what it does Landlock is a Python wrapper around the Linux Landlock security module, which lets you restrict file system access at runtime by defining allow/deny rules. You create a Ruleset, specify which paths are accessible, call apply(), and from that point forward the process and its children cannot read, write, or interact with files outside the allowed set—even through symlinks or other escape routes. It supports Landlock ABI versions 1, 2, 3, and 5, covering initial access control, file renaming/linking, truncation, and device IOCTL operations. The package is useful for hardening long-running services (like HTTP servers) against both accidental programming mistakes and exploits. If a vulnerability is discovered in your application, Landlock can prevent the attacker from reading sensitive files or accessing the full file system. It won't stop all malicious behavior, but it significantly raises the bar for post-exploitation damage. The implementation is straightforward: define rules declaratively, apply them once, and the kernel enforces them thereafter. Use it for: - Harden HTTP or file servers to prevent symlink escapes and restrict access to a single directory. - Sandbox untrusted or third-party Python code to limit file system damage if it is compromised. - Protect sensitive application data by restricting access to configuration or credential files. - Enforce principle of least privilege in multi-tenant or containerized deployments. - Mitigate accidental file access bugs by explicitly declaring which paths an application may touch. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Landlock provides a Python interface to Linux's Landlock security module, enabling rule-based file system access restrictions to harden applications against unauthorized file access. Yes, if you run Python on Linux and need file system sandboxing. The package is actively maintained, has no dependencies, installs easily, and solves a real security problem. The main constraint is that it requires Linux with Landlock kernel support (available in recent kernels) and Python >=3.9. Not applicable on other operating systems. ## Install pip install landlock uv add landlock poetry add landlock ## Installing landlock Before you install: Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of 2026-08-10 with regular releases since first publication in 2022-08-21. License in practice: MIT license (permissive) — you can use, modify, and distribute this package freely with minimal restrictions. Quickstart: pip install landlock from landlock import Ruleset rs = Ruleset() rs.allow(".") rs.apply() Requires Linux kernel with Landlock support; requires Python >=3.9. Verify before relying: - Whether Landlock ABI versions 4, 6, and 7 (marked unsupported) are planned for future release. - Performance overhead of Ruleset enforcement under typical application workloads. - Compatibility with specific Linux kernel versions and distributions. ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 1.7M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags linux file system access control, sandboxing python applications, landlock security module, restrict file access python, linux security hardening, application sandboxing, permission-based file restrictions, linux-security, sandboxing, access-control [View on SkillFed](https://skillfed.io/packages/landlock) · [View on PyPI](https://pypi.org/project/landlock/)