Skip to content

Add Linux Gather Environment Variable Secrets module#21216

Open
bcoles wants to merge 1 commit intorapid7:masterfrom
bcoles:enum_env_secrets
Open

Add Linux Gather Environment Variable Secrets module#21216
bcoles wants to merge 1 commit intorapid7:masterfrom
bcoles:enum_env_secrets

Conversation

@bcoles
Copy link
Copy Markdown
Contributor

@bcoles bcoles commented Apr 1, 2026

Metasploit post module implementation of envex.

Extracts environment variables from all accessible processes via
/proc/<pid>/environ on Linux and flags potential secrets using a
three-layer detection engine: name heuristics, value pattern matching,
and Shannon entropy analysis.

Environment variables are a primary vector for secret exposure in modern
infrastructure. Processes receive sensitive values such as API keys,
database credentials, and tokens through their environment. These persist
in /proc/<pid>/environ for the lifetime of the process and are readable
by any process with the same UID (or by root).

In practice, many hardened environments that block memory inspection
still permit reading /proc/<pid>/environ for same-user processes.

Verification Steps

  1. Start msfconsole
  2. Get a session on a Linux target
  3. Do: use post/linux/gather/enum_env_secrets
  4. Do: set SESSION <session_id>
  5. Do: run
  6. You should see environment variables analyzed and any detected secrets reported

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Metasploit post module to enumerate /proc/<pid>/environ on Linux, analyze environment variables for potential secrets, and save both raw environment data and a flagged-secrets report as loot.

Changes:

  • Introduces post/linux/gather/enum_env_secrets, implementing name heuristics, provider token regex matching, and entropy-based detection.
  • Stores two loot artifacts: full environment variables and a filtered secrets report with confidence levels.
  • Adds user-facing module documentation including options and example output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
modules/post/linux/gather/enum_env_secrets.rb New post module that enumerates /proc environments and flags likely secrets via 3-layer detection.
documentation/modules/post/linux/gather/enum_env_secrets.md Documentation for usage, options, and sample output for the new module.

@bcoles bcoles force-pushed the enum_env_secrets branch from 6574909 to d3da3a3 Compare April 2, 2026 15:46
@bcoles
Copy link
Copy Markdown
Contributor Author

bcoles commented Apr 2, 2026

Broken tests are not my fault.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants