Skip to content

Security Model

Threat Model

TELECOM-NET-SIM is designed for offline, single-host operation. The threat model assumes:

  • The host is trusted.
  • The dashboards are accessed from the same machine (127.0.0.1).
  • No data ever leaves the host.

Guarantees

Zero external network calls

Verified by static analysis. The following tokens are scanned across all top-level and package modules:

requests, urllib, http.client, aiohttp, httpx, urlopen, socket.socket, socket.create_connection, websocket, telnetlib, ftplib, smtplib, paramiko, http.server, flask, fastapi.

Run the check yourself:

python generate_evidence.py

Result (in EVIDENCE.md):

No network imports or calls found.

Streamlit telemetry disabled

.streamlit/config.toml:

[server]
address = "127.0.0.1"

[browser]
gatherUsageStats = false

[server]
enableCORS = true
enableXsrfProtection = true

Loopback-only binding

All dashboards bind to 127.0.0.1. Verify with:

netstat -ano | findstr :8501

Every address must be 127.0.0.1. Red flags: 0.0.0.0:8501 or [::]:8501.

Password hashing

Admin passwords use scrypt with parameters:

  • n = 2^14
  • r = 8
  • p = 1
  • dklen = 32

Salt is 16 random bytes from secrets.token_bytes(). Comparison uses hmac.compare_digest (constant-time).

Login rate-limiting

5 failed attempts within 15 minutes triggers a lockout. The counter lives in audit_log (not session_state), so browser refresh and app restart cannot bypass it.

Backup integrity

  • WAL-aware snapshots via sqlite3.Connection.backup()
  • PRAGMA quick_check before restore
  • Path-traversal protection: filename must not contain / or backslash

Static analysis (bandit)

bandit runs on every push and on a weekly schedule.

bandit -c pyproject.toml -r .

Current result: No issues identified.

The following checks are intentionally skipped in pyproject.toml:

Rule Reason
B101 (assert) Used for internal invariants; not production code
B110 / B112 (try/except/pass or continue) Deliberate defensive code
B311 (random) Deterministic simulation with a fixed seed, NOT crypto
B404 / B603 / B607 (subprocess) Only spawns our own simulator via sys.executable

The remaining B608 (SQL) findings are documented as # nosec with a comment explaining why the table/column names are safe (they come from a hardcoded list, not user input).

Dependency audit (pip-audit)

pip-audit scans requirements.txt and requirements-ci.txt for known CVEs.

pip-audit -r requirements-ci.txt
pip-audit -r requirements.txt

Current result:

No known vulnerabilities found

The runtime scan is informational only; the CI scan fails the job on any finding in the minimal CI set.

Automated checks in CI

The .github/workflows/security.yml workflow runs:

  1. bandit -- static analysis
  2. pip-audit on requirements-ci.txt -- hard fail on findings
  3. pip-audit on requirements.txt -- informational

Triggers:

  • Every push touching Python code or dependencies
  • Every PR touching the same
  • Weekly (Monday 06:00 UTC / 09:30 Tehran)

Evidence

EVIDENCE.md is auto-generated by generate_evidence.py and proves the guarantees above at any point in time:

python generate_evidence.py

It scans the codebase, reads .streamlit/config.toml, verifies imports, and produces a report you can attach to a delivery.

Reporting a vulnerability

Please do not open a public issue. Instead, use GitHub's private security advisory form.