Developer laptops hold long-lived cloud keys, registry tokens and cluster credentials in well-known plaintext files, and infostealers read those paths first. The command line tools that engineers use every day (AWS CLI, npm, Docker, kubectl, gcloud, Azure CLI, Git, GitHub CLI, Twine) each have a default place where they keep a credential, and several of those places are plain files protected only by file permissions. This guide is an audit how-to: where each file lives, what a finding looks like, how to scan a fleet without collecting secret values, how to move each tool to a safer store, and how to detect unexpected reads. It is written for endpoint, platform and security engineering teams. For what to do once a laptop is known to be compromised, use the response playbook linked below; this page is about finding and removing the exposure before that happens.
Key takeaways
- The paths are documented and predictable.
~/.aws/credentials,~/.npmrc,~/.docker/config.json,~/.kube/config,~/.git-credentialsand~/.pypircare named in the tools' own documentation, which is why credential-stealing malware targets them. - Several vendors say plainly that the file is plaintext. AWS calls its shared files "plaintext files", Git warns its store helper keeps passwords "unencrypted on disk", the PyPA warns that
.pypirc"stores your password in plain text", and Microsoft states the Azure CLI token cache is plaintext on Linux and macOS. - Audit for presence and type, never collect values. A fleet scan should report which files exist, which credential types they contain and their age, so the scan itself does not become a new secret store.
- Every tool has a safer mode. OS keychains through credential helpers, short-lived federated sessions (IAM Identity Center, OIDC cluster sign-in), and environment references replace most long-lived file secrets.
- Measure the trend, not one scan. Track hosts with long-lived cloud keys, unscoped or plaintext registry tokens and static kubeconfig tokens over time, and alert on reads of these paths by unexpected processes.
Why these files matter
A developer laptop is where human identity and machine identity meet. The engineer signs in with phishing-resistant MFA, then a CLI writes a token that works without MFA until it expires or is revoked. ATT&CK tracks this as T1552.001 Unsecured Credentials: Credentials In Files and T1552.004 Private Keys, and the related T1555 Credentials from Password Stores covers theft from keychains and credential managers. Infostealer families and malicious packages harvest exactly these locations: the ChainDrop npm worm collected npm tokens, GitHub tokens, AWS, Google Cloud and Azure credentials, Kubernetes tokens, Docker configuration and SSH keys from developer machines and CI runners, along with credential files for AI coding tools.
The exposure is also about what the token can reach. In the LastPass 2022 breach a senior DevOps engineer's home computer was compromised and the attacker used AWS access keys and backup decryption keys reached from that engineer's access to copy cloud backups. One endpoint, one set of machine credentials, a large blast radius. See the Developer endpoints as NHI stores guide for the wider argument, and the Infostealer Threat Guide for how stealer malware operates.
Where each tool stores credentials
The table lists default locations from each tool's own documentation. Environment variables can move a file, so an audit should also check them.
| Tool | Default location | What can be in it | Override |
|---|---|---|---|
| AWS CLI and SDKs | ~/.aws/credentials and ~/.aws/config (Windows: %UserProfile%\.aws\); SSO tokens in ~/.aws/sso/cache; assumed-role credentials in ~/.aws/cli/cache | aws_access_key_id, aws_secret_access_key, aws_session_token, or a credential_process command | AWS_SHARED_CREDENTIALS_FILE, AWS_CONFIG_FILE |
| npm | Per-user ~/.npmrc; per-project .npmrc in the repository root; global $PREFIX/etc/npmrc | _authToken, _auth, username and _password, client certfile and keyfile | userconfig and globalconfig parameters |
| Docker CLI | $HOME/.docker/config.json (Windows: %USERPROFILE%/.docker/config.json) | Base64-encoded registry credentials when no credential store is configured; otherwise credsStore or credHelpers entries naming a helper | Docker config directory settings |
| kubectl | $HOME/.kube/config | Bearer tokens, embedded client certificates and keys, or exec plugin commands that fetch a token | KUBECONFIG variable, --kubeconfig flag |
| Google Cloud ADC | $HOME/.config/gcloud/application_default_credentials.json (Windows: %APPDATA%\gcloud\) | User refresh credentials from gcloud auth application-default login; elsewhere, service account key files | GOOGLE_APPLICATION_CREDENTIALS points to a key or federation config file |
| Azure CLI | Files under ~/.azure | MSAL token cache and service principal entries: encrypted on Windows, plaintext on Linux and macOS according to Microsoft | AZURE_CONFIG_DIR |
| Git | ~/.git-credentials or $XDG_CONFIG_HOME/git/credentials (default ~/.config/git/credentials) when the store helper is used | One URL per line with user name and password or token | --file option of the helper |
| GitHub CLI | System credential store by default; a plain text file if no store is available or --insecure-storage is used (gh auth status shows where) | OAuth token or personal access token | GH_TOKEN environment variable |
| Python packaging (Twine) | $HOME/.pypirc | username = __token__ and a PyPI API token as password | Keyring or environment variables |
| Terraform CLI | CLI configuration (.terraformrc in the home directory, terraform.rc in %APPDATA% on Windows) and the file terraform login writes | API tokens in credentials blocks | TF_TOKEN_ variables, credentials_helper |
Beyond the table, an audit usually also covers SSH private keys in ~/.ssh (see the SSH Key Management Guide), .env files in working copies, shell history files that captured a token typed on the command line, and the credential files of AI coding assistants, which the ChainDrop write-up shows are now on stealer target lists.
What a finding looks like, and how serious it is
Not every file is equally risky. A file that holds a pointer to a keychain helper is fine; a file that holds a permanent key to production is not. Grade findings so the remediation queue starts with the worst.
| Finding | Severity | Why |
|---|---|---|
~/.aws/credentials with an access key ID starting AKIA (long-term IAM user key) | Critical | Works from anywhere until rotated; no MFA on use. AWS recommends federation such as IAM Identity Center instead. |
Service account key JSON on disk, or GOOGLE_APPLICATION_CREDENTIALS pointing to one | Critical | Google states service account keys "create a security risk and are not recommended". |
Unscoped _authToken in .npmrc, or a publish-capable token | High | npm documents an unscoped token as a "bad config"; publish rights enable a supply chain attack. |
kubeconfig with a static token or client-key-data for a production cluster | High | Static cluster credentials outlive the user's IdP session and bypass its policies. |
~/.git-credentials or .pypirc with a token | High | Plaintext by design, as the Git and PyPA docs state. |
auths entries with an auth value in ~/.docker/config.json | Medium to high | Base64 is encoding, not encryption; severity depends on registry push rights. |
| Azure CLI token cache on Linux or macOS | Medium | Tokens expire, but refresh tokens extend the window; treat as session theft risk. |
AWS SSO cache, credential_process, Docker credsStore, kubeconfig exec plugin | Low (expected) | Short-lived or keychain-backed. Still check file permissions and session length. |
How to audit a fleet safely
The audit must not create a new honeypot. Design it so that no secret value ever leaves the endpoint.
- Collect metadata only: path, owner, permission bits, size, modification time, and a classification label (for example "AWS long-term key present", "npm token unscoped"). Classify on the endpoint with pattern checks, then discard the matched text.
- Use the tooling you already trust: an EDR live query, an MDM script with read-only rights, or an osquery-style file table. Avoid ad hoc scripts that upload file contents to a share.
- Cover every user profile: laptops often hold old profiles, WSL distributions and dev containers with their own home directories. Include
/home/*,/Users/*,C:\Users\*and WSL file systems in scope. - Check environment and shell configuration: exported
AWS_ACCESS_KEY_ID,GH_TOKEN,NPM_TOKENorTF_TOKEN_*lines in.zshrc,.bashrcor PowerShell profiles are the same exposure in a different file. - Check permissions as a secondary finding: a credential file readable by group or others (anything looser than 600 on Unix) is worse; the PyPA guidance explicitly recommends
chmod 600 ~/.pypirc. - Record the owner and team: remediation is a conversation with an engineer, so the finding must route to a person, not just a hostname.
- Handle the data as sensitive: even metadata reveals which hosts hold production access. Restrict the results to the security team and set a retention period.
Pair the endpoint scan with repository and pipeline scanning, because the same tokens leak into commits and CI logs. See the Developer Secret Scanning Triage guide.
Moving each tool to a safer store
For each finding there is a documented safer configuration. The aim is short-lived credentials obtained from the identity provider, or long-lived ones held in an OS keychain behind the user's login.
| Tool | Replace | With |
|---|---|---|
| AWS CLI | Long-term keys in ~/.aws/credentials | IAM Identity Center profiles with aws sso login (temporary role credentials), or credential_process calling a vault or keychain. See the AWS Access Keys Security Guide. |
| npm | Plaintext _authToken in ~/.npmrc | A registry-scoped entry using ${VARIABLE} substitution filled from a secrets tool at run time, read-only tokens for installs, and trusted publishing from CI instead of laptop publishing. See the npm Tokens Security Guide. |
| Docker | Base64 auths in config.json | credsStore set to osxkeychain, wincred, pass or secretservice, or per-registry credHelpers. See the Docker Desktop Security guide. |
| kubectl | Static tokens and client keys | An exec credential plugin that obtains short-lived tokens through the IdP or cloud provider sign-in. Only accept kubeconfig files from trusted sources, as the Kubernetes docs warn a crafted file can run code. |
| Google Cloud | Service account key files | User ADC from gcloud auth application-default login for local development and service account impersonation where a service identity is needed. |
| Git | credential.helper store | An OS-integrated helper (macOS Keychain, Windows Credential Manager, libsecret) or git-credential-cache, as the Git docs suggest, and SSH or signed commits with hardware-backed keys. |
| GitHub CLI | Plain text token file | Default system credential store; remove --insecure-storage from onboarding scripts. |
| Twine and PyPI | Token in .pypirc | Keyring storage, and trusted publishing from CI. See the PyPI API Tokens and Trusted Publishing Security Guide. |
| Terraform | Tokens in CLI configuration | A credentials_helper, or TF_TOKEN_ variables injected for the session. |
Choosing between options
- Federated short-lived session vs keychain: prefer federation whenever the platform supports it, because a stolen token expires and access follows the IdP's conditional access. Use a keychain where only a static token exists (many package registries), since the keychain at least ties access to the logged-in user.
- Keychain vs environment injection: environment variables are visible to every child process and often end up in shell history or crash dumps. Inject per command (a secrets tool that wraps the command) rather than exporting in shell profiles.
- Small organisations: start with AWS federation, Docker and Git credential helpers, and a ban on publish tokens on laptops. That removes most critical findings with little tooling.
- Large organisations: manage developer CLI configuration centrally (MDM-delivered config, golden dev container images), and make the endpoint scan part of device compliance so a laptop with a long-lived production key fails posture. See the Device Trust and Posture Guide.
Implementation: a phased rollout
- Baseline (weeks 1 to 2): run the metadata-only scan on a pilot ring of volunteer engineers across macOS, Windows and Linux. Validate classifiers against known test files so the counts are trustworthy.
- Fix the criticals (weeks 2 to 4): for each long-lived cloud key or service account key, the owner rotates and deletes it, and switches to federation. Revoke at the provider; deleting the local file alone leaves the key valid.
- Change defaults (weeks 3 to 6): ship managed configuration: Docker
credsStore, Git OS helper, AWS SSO profiles, kubeconfig exec plugins. Update onboarding documentation and scripts so new laptops start clean. - Widen to the fleet (weeks 6 to 10): extend the scan to all engineering endpoints, then to everyone with CLI access to production (data, SRE, support).
- Enforce (after 10 weeks): add "no long-lived production credential files" as a device compliance condition in report-only mode first, then block access from non-compliant devices to sensitive applications.
- Roll back safely: keep the previous credential path documented for each tool during the switch, and do not revoke a team's old key until its federated profile has been used successfully. If a helper breaks builds, revert the managed configuration for that ring, not the whole fleet.
Detection and measurement
What to watch
- Unexpected readers: EDR file-access telemetry on the paths in the first table, alerting when a process other than the owning tool (for example anything other than
aws,kubectl,docker, an IDE or the shell) opens them, especially processes started from download or temp folders, package install scripts and browser child processes. - Bulk access: one process touching several credential paths within seconds is a stealer pattern, regardless of the binary name.
- Use from unusual locations: on the provider side, alert when a key or token tied to a laptop user is used from an IP, ASN or country outside the norm (CloudTrail, Google Cloud audit logs, Entra sign-in logs, npm and GitHub audit logs).
- Stealer intelligence: monitor for your domains and tokens in infostealer log feeds. See the Infostealer Logs Monitoring and Response Guide.
Metrics
| Metric | Target direction |
|---|---|
| Endpoints with long-lived cloud keys or service account key files | Down to zero for production accounts |
Endpoints with plaintext or unscoped registry tokens (npm, PyPI, Docker auths) | Down quarter on quarter |
| kubeconfig contexts using static tokens or client keys for production clusters | Zero |
| Median age of credential files found | Down; old files signal abandoned keys |
| Time from finding to revocation at the provider for critical findings | Under 5 working days |
| Share of engineering endpoints covered by the scan in the last 30 days | Above 95 percent |
Common failure patterns
- Deleting the file, not the credential: a key copied by a stealer last month still works. Rotation and revocation happen at the provider, then the file is removed.
- A scan that uploads secrets: collecting file contents "for triage" builds a central store of every engineer's keys. Classify on the device and ship labels only.
- Ignoring per-project files: scanning only home directories misses
.npmrcand.envfiles committed or left in working copies, which also leak through repositories and container builds. - Forgetting secondary environments: WSL, dev containers, virtual machines and old user profiles each have their own
~/.awsand~/.kube. - Publishing from laptops: a publish-capable registry token on an engineer's laptop turns one infostealer infection into a supply chain incident, as the npm worm cases show. Publish from CI with trusted publishing instead. See the Shai-Hulud npm Worm Guide.
- Treating encoding as protection: base64 in Docker
config.jsonand file permissions on Linux and macOS stop casual browsing, not malware running as the user.
Framework mapping
| Framework | Reference | How it applies |
|---|---|---|
| MITRE ATT&CK | T1552.001 Credentials In Files; T1552.004 Private Keys; T1555 Credentials from Password Stores | The techniques this audit reduces and the detection rules target |
| NIST SP 800-53 Rev 5 | IA-5(7) No Embedded Unencrypted Static Authenticators; IA-5 Authenticator Management; CM-6 Configuration Settings | Removing plaintext authenticators and enforcing managed tool configuration |
| NIST CSF 2.0 | PR.AA-01; PR.DS-01; DE.CM-09 | Managed credentials for users and services, protecting data at rest, and monitoring endpoints |
| CIS Controls v8.1 | Control 3 Data Protection; Control 5 Account Management; Control 6 Access Control Management | Inventory and protection of sensitive data and credentials |
Practitioner checklist
- Build a metadata-only scan for the credential paths in this guide, including WSL, dev containers and every user profile.
- Grade findings by credential type and reach, and route each one to its owner.
- Revoke at the provider every long-lived cloud key and service account key found, then remove the file.
- Move AWS to IAM Identity Center profiles and kubectl to exec plugin sign-in.
- Ship managed Docker
credsStoreand Git OS credential helper configuration. - Remove publish-capable npm and PyPI tokens from laptops and publish from CI with trusted publishing.
- Strip exported tokens from shell profiles and onboarding scripts, including
--insecure-storage. - Alert on credential file reads by unexpected processes and on bulk access to several paths.
- Report the six metrics monthly and add the condition to device compliance once the baseline is low.
Standards and references
- AWS: Configuration and credential file settings in the AWS CLI
- npm Docs: npmrc
- Docker Docs: docker login
- Kubernetes: Organizing Cluster Access Using kubeconfig Files
- Google Cloud: How Application Default Credentials works
- Microsoft Learn: Azure CLI migration to MSAL
- Git: git-credential-store documentation
- Python Packaging Authority: The .pypirc file
Related NHI Mgmt Group resources: Compromised Developer Workstation Playbook · Developer endpoints as NHI stores · Developer Workstation and IDE Security Guide · Infostealer Threat Guide