OWASP / OWASP/Nettacker

Arbitrary code execution via exec() in response_conditions_matched

Open
#1,408 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

duplicate
Dominant language
Python
Stars
5.6k
Forks
1.2k
Avg merge
1d 21h
Merged PRs (30d)
16

Description

Summary
response_conditions_matched() in nettacker/core/lib/http.py evaluates the responsetime condition using exec() with an operator taken directly from module YAML.

This allows arbitrary Python execution if a crafted module provides a malicious condition string.

Location:
nettacker/core/lib/http.py
~line 95
Vulnerable pattern
exec(
f"matched = response['responsetime'] "
f"{conditions['responsetime'].split()[0]} "
f"{conditions['responsetime'].split()[1]}"
)

Since the operator comes from YAML, a condition like:

conditions:
responsetime: ">= 0 or import('os').system('id')"

would execute arbitrary code during scan.

Fix

Replace exec() with explicit operator dispatch:

ops = {
'==': float.eq,
'!=': float.ne,
'>=': float.ge,
'<=': float.le,
'>': float.gt,
'<': float.lt,
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in nettacker/core/lib/http.py around response_conditions_matched() and inspect how the responsetime condition is parsed. Verify the supported comparison operators and ensure crafted module YAML cannot execute arbitrary Python while valid comparisons still work. Done means the dynamic exec() path is removed and the condition behavior remains covered by verification of safe and malicious inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.