skillfed

safe-netrc

Safe netrc file parser

safe-netrc v1.0.1 93.2K downloads/30d#13,397 on PyPI
Copyleft license GPL-2.0-or-later Abandoned released

What it is and what it does

Safe-netrc is a drop-in replacement for Python's standard library netrc parser that adds stricter security and flexibility. It extends the netrc.netrc class to enforce file permissions checks and allows the netrc file path to be specified via the NETRC environment variable instead of always defaulting to ~/.netrc. The package backports permission validation that was added to the standard library in Python 3.1, ensuring consistent security behavior across Python versions.

The package is intended for applications that need to read authentication credentials from netrc files while maintaining strict security posture. It has no external runtime dependencies and installs as a pure Python wheel, making it lightweight and portable. However, the project is no longer actively maintained—the last release was in November 2022.

Use it for:

  • Secure credential lookup in CLI tools or scripts that need to authenticate with remote services using netrc files.
  • Enforcing strict file permissions on credential files to prevent accidental exposure of passwords.
  • Allowing deployment scripts to override the default netrc location via NETRC environment variable for non-standard configurations.
  • Backporting secure netrc parsing to Python 3.7–3.9 environments where standard library behavior may differ.
  • Validating netrc file permissions in security-sensitive applications before attempting to read credentials.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a safer subclass of Python's standard netrc parser that enforces strict file permissions and supports custom netrc file paths via environment variable.

Yes, if you need secure netrc parsing with strict permissions checks and environment-variable path override in a Python 3.7+ application. The package is stable and has no known vulnerabilities, but be aware it is abandoned and will not receive updates. Use it only if the current behavior meets your needs and you do not expect future maintenance.

Install

safe-netrc on PyPI

pip

pip install safe-netrc

uv

uv add safe-netrc

poetry

poetry add safe-netrc

Installing safe-netrc

Before you install

Low friction: pure Python wheel with no runtime dependencies. However, the package is abandoned—last release was 2022-11-29, over 1354 days ago. No active maintenance or security updates.

License in practice

GPL-2.0-or-later is a copyleft license requiring derivative works to be licensed under compatible terms. Any code that imports and modifies this package must be released under GPL-2.0-or-later or a compatible license.

Quickstart

pip install safe-netrc

from safe_netrc import netrc
auth = netrc()
login, _, password = auth.authenticators('example.com')

Requires Python 3.7 or later. The netrc file must have restrictive permissions or the parser will reject it.

Verify before relying

  • Whether the abandoned status affects real-world use cases where netrc handling is stable and rarely needs updates.
  • Specific permission requirements the parser enforces on netrc files.
  • Whether permissions-check backport from Python 3.1 remains relevant given current Python version support (3.7+).

Package facts

License GPL-2.0-or-later (copyleft)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance abandoned — 1,354 days since the last release
First released
Downloads 93,230/month — #13,397 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: safe_netrc-1.0.1-py3-none-any.whl

Development Status :: 5 - Production/StableEnvironment :: ConsoleLicense :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)Operating System :: POSIXProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: InternetTopic :: Security

Tags

netrc file parsersecure credential storagenetrc permissions checkenvironment variable netrc pathsafe authentication filenetrc securitycredential file validation
credentialsauthenticationsecurity-hardening

More Internet packages