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

Should not match

Known false positives

References