API access key and scan IDs generated with a non-cryptographic PRNG (CWE-338)
Affected versions: current master and latest release.
Summary: generate_random_token() builds secrets using Python's random module (Mersenne Twister), restricted to lowercase a–z:
nettacker/core/utils/common.py:386
def generate_random_token(length=10): return "".join(random.choice(string.ascii_lowercase) for _ in range(length)) It is used for the API access key (nettacker/config.py:66, generate_random_token(32)) — the sole secret protecting the Web UI, scan launching and all result data — and for scan_id (nettacker/core/app.py:218).
Impact: random is not a CSPRNG; its internal state is recoverable from observed outputs, and the lowercase-only charset shrinks the space further. An attacker able to observe tokens (e.g. predictable scan_ids) could work toward predicting the API key, which grants full API access.
Fix: generate secrets with the secrets module (secrets.choice / secrets.token_urlsafe). The codebase already uses secrets.token_hex(32) at nettacker/api/engine.py:69, so this aligns it. Related hardening in the same report: use secrets.compare_digest for the key check (nettacker/api/core.py:142, currently !=, CWE-208), and stop accepting the API key via GET query string since it is written to the access log (nettacker/api/engine.py:179-190), which also lacks CRLF sanitization (log injection).
Issue #1 (bug) Title: Unhandled 500 (NoneType) on non-existent scan id in /results/get_json and /results/get_csv
A valid API client that requests a result id that doesn't exist triggers an unhandled AttributeError → HTTP 500.
session.query(Report).filter(Report.id == result_id).first() returns None, then .scan_unique_id is dereferenced without a guard:
nettacker/api/engine.py:507-509 (/results/get_json) nettacker/api/engine.py:530-531 (/results/get_csv) By contrast /results/get (engine.py:482-485) already wraps DB access in try/except, so the behaviour is inconsistent.
Expected: return a clean 400/404 JSON error (like the other endpoints) when the report isn't found.
OS: Windows 11 OS Version: 10.0.26200 Python Version: 3.12.10
Issue #2 (improvement) Title: CSV result/log endpoints write report files into the process working directory
/results/get_csv (engine.py:536-541) and /logs/get_csv (engine.py:621-627) build a bare filename with no directory and open(filename, "w"), writing a CSV into the process CWD just to read it back and return it. This litters the CWD, isn't confined to results_dir, and /results/get_csv uses a fixed name that races across concurrent requests.
Suggested fix: build the CSV in memory with io.StringIO, or write under Config.path.results_dir with a unique name and clean up.
OS: Windows 11 OS Version: 10.0.26200 Python Version: 3.12.10
Issue #3 (feature) Title: Add a version → CVE mapping layer for *_version_scan modules
The version scanners (e.g. jenkins_version_scan, confluence_version_scan, and the new grafana_version_scan from #1799) now emit clean version strings. A mapping layer that flags known CVEs for a detected version would turn version detection into actionable findings — the "planned version-to-CVE mapping feature" referenced in #1799.
Scope to discuss: data source/format for version→CVE ranges, where mapping runs (post-processing vs. report), and output in reports.
OS: Windows 11 OS Version: 10.0.26200 Python Version: 3.12.10
I'd like to work on this, could it be assigned to me? I've already looked into the fix and can put up a PR.
@Sickwoman This is a duplicate. Please be respectful to other contributors and always check other issues and PRs first - see: #1463 , #1584
@Sickwoman This is a duplicate. Please be respectful to other contributors and always check other issues and PRs first - see: #1463 , #1584
Sorry for the inconvenience. I will be more careful from now on while generating the issue.
Thanks