Skip to content

Instantly share code, notes, and snippets.

@ajinabraham
Last active January 31, 2021 15:07
Show Gist options
  • Save ajinabraham/5f6f8dc4a7f222725ad03bac524f9c55 to your computer and use it in GitHub Desktop.
Save ajinabraham/5f6f8dc4a7f222725ad03bac524f9c55 to your computer and use it in GitHub Desktop.
rules:
- id: env-set
patterns:
- pattern-either:
- pattern: |
subprocess.check_output([..., "=~/env|set/", ...])
- pattern: |
subprocess.run([..., "=~/env|set/", ...])
- pattern: |
subprocess.Popen([..., "=~/env|set/", ...])
message: |
Reading from env or set commands
severity: ERROR
languages:
- python
- id: python-os-environ
patterns:
- pattern-not-inside: os.environ.get(...)
- pattern-not-inside: os.environ[...]
- pattern-either:
- pattern: |
os.environ
message: |
Reading from python's os.environ()
severity: ERROR
languages:
- python
- id: python-proc-fs
patterns:
- pattern-either:
- pattern: |
pathlib.Path('/proc') / ... / 'environ'
message: |
Reading python /proc/<pid>/environ
severity: ERROR
languages:
- python
- id: environ-files
patterns:
- pattern-inside: |
$X = {..., "=~/\/etc\/environment|\/etc\/profile|\/etc\/bashrc|~\/.bash_profile|~\/.bashrc|~\/.profile|~\/.cshrc|~\/.zshrc|~\/.tcshrc/", ...}
...
- pattern-either:
- pattern: |
Path(...)
- pattern: |
open(...)
message: |
Reading from sensitve files that contain environment variables
severity: ERROR
languages:
- python
- id: libc-environ
patterns:
- pattern-either:
- pattern: |
$LIB = ctypes.CDLL(...)
...
$Y.in_dll($LIB, 'environ')
message: |
Reading from libc.environ
severity: ERROR
languages:
- python
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment