Netrc Credentials (.netrc / _netrc)
Detects login and password entries from a .netrc file (_netrc on Windows), the plaintext auto-login file read by curl, git, ftp, pip, Heroku and many other command-line tools. An entry names a host (machine, or the catch-all default) and supplies the login and password used for it, on one line or spread across several. npm supply-chain worms and infostealers in 2026 harvested ~/.netrc because one file often holds source-control, package-registry and deployment credentials together.
- Type
- regex
- Engine
- boost_regex
- Confidence
- medium
- Confidence justification
- Medium confidence. The netrc grammar is documented by GNU inetutils and curl and the machine/login/password token sequence is rare outside real netrc content, but the tokens are ordinary English words and the password has no fixed shape, so the regex cannot tell a live secret from a stale or invented one. Enforce tiers therefore require the host token as well as the login/password pair and reject placeholder values.
- Jurisdictions
- global
- Regulations
- Criminal Code Act 1995 (Cth), Computer Fraud and Abuse Act, Computer Misuse Act 1990
- Frameworks
- CIS Controls, ISO 27001, NIST CSF, SOC 2
- Data categories
- credentials, security
- Scope
- narrow
- Risk rating
- 8
- Platform compatibility
- Purview: Compatible, GCP DLP: Unsupported, Macie: Unsupported, Zscaler: Compatible, CrowdStrike DLP: Unsupported, Palo Alto: Unsupported, Netskope: Unsupported
Pattern
(?i)(?<![A-Za-z0-9_-])(login\s+(?!anonymous\s)[^\s]{1,128}(?:\s+account\s+[^\s]{1,128})?\s+password\s+(?!"?(?:<|\*{3}|x{4}|\$|your|pass(?:word|wd)?\b|secret\b|token\b|changeme|redacted))(?:"[^"\n]{1,128}"|[^\s"]{1,256})|password\s+(?!"?(?:<|\*{3}|x{4}|\$|your|pass(?:word|wd)?\b|secret\b|token\b|changeme|redacted))(?:"[^"\n]{1,128}"|[^\s"]{1,256})\s+login\s+[^\s]{1,128})
Corroborative evidence keywords
machine, default, .netrc, _netrc, netrc
Proximity: 300 characters
Should match
login deploy password ABCDEFGHIJKLMNOP0123— Exact 65 probe - login/password token pair with no machine or default tokenmachine git.internal.corp login deploy password ABCDEFGHIJKLMNOP0123— Exact 75 probe - single-line netrc entrymachine registry.internal.corp login ops@corp.internal password ABCDEFGHIJKLMNOPQRSTUVWXYZ012345— Exact 75 probe - one entry spread across lines, as most .netrc files are writtendefault login svc-backup password ABCDEFGHIJ0123456789— Exact 75 probe - default entry with a real loginmachine artifacts.internal.corp password ABCDEFGHIJKLMNOP0123 login deploy— Exact 75 probe - password token before the login token (the grammar fixes no order)machine ftp.internal.corp login backup account ops password ABCDEFGHIJ0123456789— Exact 75 probe - account token between login and passwordmachine nas.internal.corp login backup password "ABCDEF GHIJKL 012345"— Exact 75 probe - double-quoted password containing spaces (curl 7.84.0 and later)machine github.com login buildbot password ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef0123 machine pypi.internal.corp login __token__ password abcdefghijklmnopqrstuvwxyz012345— Exact 85 probe - two distinct entries in one file$ cat ~/.netrc machine build.internal.corp login svc-ci password 0123456789ABCDEFGHIJ— Exact 85 probe - one entry with a netrc file referencemachine vault.internal.corp password ABCDEFGHIJKLMNOP0123— Discovery only - machine and password with no login token
Should not match
default login anonymous password user@site— The anonymous FTP default from the GNU inetutils manual is not a secretmachine example.com login daniel password qwerty— The curl documentation example; the shared template exclusion vetoes its example.com hostmachine git.internal.corp login deploy password <your-token>— Angle-bracket placeholder instead of a passwordmachine git.internal.corp login deploy password ${NETRC_PASSWORD}— Environment-variable reference in a netrc template, not a stored secretmachine git.internal.corp login deploy— Entry with no password tokenStore the login and the password for each machine in your netrc file.— Prose that names the tokens without an entryauth: login failed, password expired for machine build01— Log line whose words fall in login/password order with no netrc host token (discovery only)Documentation example for ~/.netrc: machine git.internal.corp login deploy password ABCDEFGHIJKLMNOP0123— Complete entry with file context, vetoed on every tier by the documentation-example framing
Known false positives
- Documentation, READMEs and CI templates that show a netrc entry with an invented password that is not one of the recognised placeholder forms. Mitigation: The regex rejects angle-bracket, starred, x-run and variable-reference values and the words password, secret and token; the shared template exclusion vetoes example.com hosts and documentation framing. Review remaining hits against the named host.
- Prose or log text where the words login and password happen to be followed by other words, such as a log line reporting a failed login. Mitigation: Such text reaches only the discovery tier. Enforce tiers require a machine <host> or default login token next to a netrc token, which ordinary sentences do not contain.
- Stale .netrc files whose passwords have been rotated or whose hosts no longer exist. Mitigation: The pattern cannot test liveness. Treat a match as a credential to rotate and confirm with the host owner.
References
- GNU inetutils manual, The .netrc file (tokens machine, default, login, password, account, macdef; separated by spaces, tabs or new-lines; the anonymous default example)
- everything curl, .netrc (single-line and multi-line entries; double-quoted strings since curl 7.84.0; _netrc on Windows)
- StepSecurity, ChainDrop npm worm, 4 August 2026 (lists ~/.netrc among the credential files harvested)