landlock
Python interface to the Landlock Linux Security Module.
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Linux kernel with Landlock support; requires Python >=3.9.
- 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 · maintenance · safety
permissive license (permissive) — MIT license (permissive) — you can use, modify, and distribute this package freely with minimal restrictions.
last release 2025-05-03 (468 days) · last repo commit 2026-08-10 · 28 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,724,754 downloads/mo, #3,612 on PyPI
Alternatives
Verify before relying
pip install landlock
from landlock import Ruleset
rs = Ruleset()
rs.allow(".")
rs.apply()- 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.
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 on this page. Verify before relying on it.
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
landlock on PyPI
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.
Requires Linux kernel with Landlock support; requires Python >=3.9.
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()
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 | permissive license permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 468 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,724,754 / month, #3,612 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3 :: OnlyTopic :: SecurityTopic :: Software Development :: Libraries :: Python ModulesTopic :: System :: Operating System Kernels :: Linux |
Evidence: landlock-1.0.0.dev5-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “linux file system access control”
- landlockLandlock provides a Python interface to Linux's Landlock security…
- pyxattrProvides Python access to extended attributes (xattr) on filesystem…
- spidevProvides Python bindings to interact with SPI devices on Linux…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also nono-py · AccessControl · pytest-socket · zope.security · redlock-py · auth · pyseccomp · fs · rules · django-pglock