Commit Graph

39 Commits

Author SHA1 Message Date
64bfeccfdb feat(mitmproxy): Add VoIP/XMPP WAF protection rules
New WAF categories for VoIP and Jabber security:

- voip: SIP header injection, ARI command injection, FreePBX RCE,
  AMI web access, multipart traversal, Digest auth attacks
- xmpp: XSS in messages/presence, BOSH hijack, XXE via XInclude,
  WebSocket XSS, HTTP upload abuse, null byte in JID
- cve_voip: Asterisk PJSIP crash (CVE-2021-26906), negative CL DoS,
  Via header overflow, Route header crash, SDP buffer overflow,
  CSeq method overflow, FreePBX/Kamailio/OpenSIPS CVEs
- cve_xmpp: Prosody namespace confusion, stream DoS, upload DoS,
  ejabberd disco leak, Converse.js XSS, Strophe.js parsing crash,
  Tigase unauth user creation

Also added:
- UCI waf_rules section with toggles for all 12 categories
- Auto-ban options for VoIP/XMPP attack patterns
- Updated waf-sync script for new categories

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-19 10:43:06 +01:00
d98bcdf7f4 fix(mitmproxy): Sync routes to all instance data paths
The sync-routes command was only writing to the default /srv/mitmproxy
path. Now copies haproxy-routes.json to all configured instances
(mitmproxy-in, mitmproxy-out) so the HAProxy router addon can
properly route traffic.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 06:13:45 +01:00
507263f6a7 fix(mitmproxy): Sync autoban config to all instances
The reload-autoban command was only writing to the default data path,
missing the mitmproxy-in and mitmproxy-out instances. Now iterates
over all configured instances to ensure autoban.json is updated
everywhere.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 06:03:46 +01:00
cac9fa3e4f fix(mitmproxy): Fix false positives for legitimate browsers
- Remove 'mozilla/5.0' from BOT_SIGNATURES - was flagging ALL modern
  browsers as bots since this is the standard UA prefix
- Fix suspicious UA detection - no longer flags normal browsers
- Increase CrowdSec bruteforce threshold from 5/30s to 10/60s to reduce
  false positives from normal login flows

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 05:51:53 +01:00
418cb2c76e fix(mitmproxy): Fix SSRF false positives for internal traffic
SSRF detection was triggering on any request to internal IPs
(192.168.x.x, 10.x.x.x, etc.) because it was checking the target
URL itself. Now only checks query parameters and request body for
SSRF patterns, which is where actual SSRF attacks occur.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 05:38:26 +01:00
5fa5924533 fix(mitmproxy): Add per-instance haproxy_router_enabled override
Allow disabling HAProxy router mode per-instance via UCI option
`mitmproxy.<instance>.haproxy_router_enabled`. This prevents port
conflicts when running multiple mitmproxy instances (e.g., mitmproxy-out
on 8888 and mitmproxy-in on 8889) where only the inbound instance
needs HAProxy router mode.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 05:21:07 +01:00
e58f479cd4 feat(waf): Update WAF scenarios with 2024-2025 CVEs and OWASP threats
Add detection patterns for latest actively exploited vulnerabilities:
- CVE-2025-55182 (React2Shell, CVSS 10.0)
- CVE-2025-8110 (Gogs RCE), CVE-2025-53770 (SharePoint)
- CVE-2025-52691 (SmarterMail), CVE-2025-40551 (SolarWinds)
- CVE-2024-47575 (FortiManager), CVE-2024-21887 (Ivanti)
- CVE-2024-3400, CVE-2024-0012, CVE-2024-9474 (PAN-OS)

New attack categories based on OWASP Top 10 2025:
- HTTP Request Smuggling (TE.CL/CL.TE conflicts)
- AI/LLM Prompt Injection (ChatML, instruction markers)
- WAF Bypass techniques (Unicode normalization, double encoding)
- Supply Chain attacks (CI/CD poisoning, dependency confusion)
- Extended SSTI (Jinja2, Freemarker, Velocity, Thymeleaf)
- API Abuse (BOLA/IDOR, mass assignment)

CrowdSec scenarios split into 11 separate files for reliability.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-12 05:02:57 +01:00
adec1144d6 feat: Streamlit ZIP flatten, mitmproxy bot whitelist, Fabricator app
- Add extract_zip_flatten() to Streamlit RPCD for nested ZIP handling
- Add bot whitelist to mitmproxy WAF (Facebook, Google, Bing crawlers)
- Skip threat detection for whitelisted legitimate crawlers
- Track Fabricator app and stats evolution in HISTORY.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-07 09:59:20 +01:00
e31e43b8d7 feat(mitmproxy): Add modular WAF rules with CVE patterns and autoban fixes
- Add waf-rules.json with 46 patterns across 8 categories:
  - sqli, xss, lfi, rce (OWASP Top 10)
  - cve_2024 (recent CVE exploits)
  - scanners, webmail, api_abuse
- Add waf_loader.py dynamic rules loader module
- Add mitmproxy-waf-sync UCI to JSON config sync script
- Fix GeoIP: install geoip2 package in container
- Fix autoban: add cron job, lower min_severity to "high"
- Enable WAF for webmail (mail.secubox.in)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-07 07:46:26 +01:00
e13b6e4c8c feat(vhost-manager): Add centralized VHost manager
- Create secubox-app-vhost-manager package for unified vhost orchestration
- Single CLI tool (secubox-vhost) manages HAProxy, DNS, Tor, Mesh, mitmproxy
- Unified UCI config (/etc/config/vhosts) as single source of truth
- Backend adapters for each component (haproxy.sh, dns.sh, tor.sh, mesh.sh, mitmproxy.sh)
- Centralized backend resolution function (backends.sh)
- Import tool for existing HAProxy vhosts
- Validation of backend reachability before creation

Also includes:
- FAQ-TROUBLESHOOTING.md with LXC cgroup v1/v2 fixes
- Fix mitmproxyctl cgroup v1 -> v2 syntax for container compatibility
- HAProxy backend resolution bugfixes

CLI commands:
  secubox-vhost add <domain> <service> <port> [--ssl] [--tor] [--mesh]
  secubox-vhost remove/list/status/enable/disable/set/sync/validate/import

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 10:16:19 +01:00
56d45fe7c2 feat(waf): Add sensitivity-based auto-ban system with CrowdSec integration
WAF Auto-ban Features:
- Three sensitivity levels: aggressive, moderate, permissive
- Aggressive: Immediate ban on first critical threat
- Moderate: Ban after 3 attempts in 5 minutes (default)
- Permissive: Ban after 5 attempts in 1 hour
- Attempt tracking with configurable thresholds

Critical threats (immediate in aggressive/moderate):
- CVE exploits, SQL injection, Command injection
- XXE, Log4Shell, SSTI attacks

CrowdSec Integration:
- Auto-ban requests written to /srv/mitmproxy/autoban-requests.log
- Cron job processes bans every minute via mitmproxyctl
- Bans sent to CrowdSec for network-wide enforcement

New Commands:
- mitmproxyctl process-autoban: Process pending bans
- mitmproxyctl reload-autoban: Reload config after UCI changes

CrowdSec Dashboard:
- Added ban button to alerts page
- Modal confirmation with 24h ban duration
- Real-time banned IP tracking

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 13:40:52 +01:00
4a8975f436 feat(mitmproxy): Disable LAN transparent proxy by default
LAN transparent mode now requires explicit opt-in via transparent.enabled
to prevent HTTPS certificate errors for LAN clients.

Changes:
- mitmproxyctl: Check transparent_enabled before setting up LAN firewall rules
- LuCI settings: Add warning about certificate requirements for LAN mode
- Default config already has transparent.enabled='0'

WAN protection mode remains active for incoming threat detection.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 10:20:59 +01:00
f4b9c910c5 feat(mitmproxy): Add WAN protection mode for incoming traffic inspection
Add WAF-like functionality to mitmproxy for protecting services exposed
to the internet. Incoming WAN traffic is redirected through mitmproxy
for threat detection before reaching backend services.

Features:
- WAN protection mode with nftables rules for incoming traffic
- Enhanced bot scanner detection with 50+ scanner signatures
- Behavioral detection for config/admin/backup/shell hunting
- CrowdSec integration with new scenarios for bot scanners
- LuCI interface for WAN protection configuration
- DPI mirror mode support (secondary feature)

New CrowdSec scenarios:
- secubox/mitmproxy-botscan: Detect automated reconnaissance
- secubox/mitmproxy-shell-hunter: Detect shell/backdoor hunting
- secubox/mitmproxy-config-hunter: Detect credential file hunting
- secubox/mitmproxy-suspicious-ua: Detect suspicious user agents

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 10:07:40 +01:00
0dd6b28d1a fix(mitmproxy): Fix HAProxy backend route sync for new-style UCI configs
The sync-routes command was failing to generate routes for most vhosts due to:
- Subshell bug: pipe in while loop caused variable changes to be lost
- Only supported old-style backends (inline .server field)
- Did not support new-style backends with separate =server sections

Changes:
- Rewrite sync-routes to avoid subshell by using temp file
- Add support for both backend styles (inline and separate server sections)
- Use original_backend field when vhosts are in inspection mode
- Skip luci/fallback/mitmproxy_inspector backends in route generation

Now properly generates 13+ routes for HAProxy backend inspection.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 16:17:29 +01:00
92f73fc3d2 feat(mitmproxy): Add HAProxy backend inspection and token auth
- Add HAProxy → mitmproxy → Backend inspection chain for filtering
  all vhost traffic through mitmproxy with threat detection
- Add haproxy_router.py addon for Host-based request routing
- Add mitmproxyctl commands: sync-routes, haproxy-enable, haproxy-disable
- Add auth token to status response for Web UI auto-authentication
- Add HAProxy Backend Inspection section to LuCI status page with
  enable/disable/sync controls
- Add HAProxy Router settings section to LuCI settings page
- LXC container now supports dual-port mode (8888 + 8889 for HAProxy)
- Token displayed with copy button in dashboard

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 15:49:05 +01:00
99aa610879 fix(mitmproxy): Fix web UI token access and transparent mode setup
- Add get_web_token to RPCD ACL permissions (was missing, causing 403)
- Add fallback token retrieval from container via lxc-attach
- Improve token capture regex to support alphanumeric tokens
- Fix startup script with background process + tee for reliable capture
- Add IP forwarding enablement for transparent proxy mode
- Fix bypass rule for traffic destined to router itself

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 07:34:22 +01:00
447e4ab2be fix(secubox-app-mitmproxy): Fix Docker image token capture for LuCI integration
- Add PYTHONUNBUFFERED=1 to ensure mitmweb output is not buffered
- Use inline while loop to capture authentication token from startup output
- Fix RPCD backend to read token from correct path ($DATA_DIR/.mitmproxy_token)
- Add proper shell detection and symlink creation in Docker rootfs extraction
- Remove unnecessary exec in pipeline that prevented output capture

The mitmweb authentication token is now properly captured and available
to the LuCI Web UI view for iframe embedding.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 09:24:45 +01:00
287bd24e3e fix(mitmproxy): Fix token capture with background job and tee
The previous pipe approach didn't work because the while loop
runs in a subshell. Now using a background job to poll the log
file for the token while tee outputs to both console and log.

Bump release to r13.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:55:34 +01:00
1dd0c95a09 feat(mitmproxy): Add embedded Web UI view with token auth
- Add get_web_token RPCD method to retrieve auth token
- Create webui.js view that embeds mitmweb in an iframe
- Capture auth token at startup and save to file
- Add Web UI navigation to all mitmproxy views
- Fix PATH for /usr/local/bin in Docker image
- Change default port from 8080 to 8888 (avoid CrowdSec conflict)

secubox-app-mitmproxy: bump to r12
luci-app-mitmproxy: bump to r2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:49:59 +01:00
63422a07b0 fix(mitmproxy): Disable web authentication for LAN access
Recent mitmproxy versions require web authentication by default.
Disable it with --set web_password= for easier LAN access.

Bump release to r11.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:37:15 +01:00
a530e8abd6 fix(mitmproxy): Change default proxy port from 8080 to 8888
Port 8080 conflicts with CrowdSec API. Using 8888 as default.

Also removes --flow-detail option not available in latest mitmproxy.

Bump release to r10.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:35:51 +01:00
e5f5b9160b fix(mitmproxy): Remove --flow-detail option not in latest mitmproxy
The --flow-detail option doesn't exist in recent mitmproxy versions.

Bump release to r9.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:31:58 +01:00
a4fe5c0a3a feat(mitmproxy): Use official Docker image for latest mitmproxy
Extract rootfs directly from mitmproxy/mitmproxy Docker image.
This provides the latest mitmproxy with all Rust components pre-compiled.

No more version compatibility issues - uses whatever version is in
the official Docker image.

Bump release to r8.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:25:03 +01:00
7f399ec429 fix(mitmproxy): Remove --flow-detail option not available in 7.x
mitmproxy 7.0.4 doesn't support the --flow-detail option which was
causing the startup script to fail.

Bump release to r7.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:20:02 +01:00
6553edba3a fix(mitmproxy): Use mitmproxy 7.0.4 for Python 3.11 compatibility
mitmproxy 8.x has dataclass compatibility issues with Python 3.11
in the grpc contentviews module.

Bump release to r6.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:04:18 +01:00
0afdfc5b78 fix(mitmproxy): Pin werkzeug<3.0 for Flask compatibility
werkzeug 3.0+ removed url_quote from werkzeug.urls which breaks
Flask imports in mitmproxy 8.1.1.

Bump release to r5.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 07:52:44 +01:00
84a6a01fc8 fix(mitmproxy): Add build-base for zstandard compilation
zstandard requires gcc to compile. Added build-base and dev packages
for compilation, then remove them after pip install to save space.

Bump release to r4.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 07:49:24 +01:00
8b784ea99e fix(mitmproxy): Use mitmproxy 8.1.1 - last pure Python version
- mitmproxy 9.x requires mitmproxy-wireguard (Rust)
- mitmproxy 10.x requires mitmproxy_rs (Rust)
- mitmproxy 8.1.1 is the last version without any Rust dependencies

Bump release to r3.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 07:49:24 +01:00
4c7c76743d fix(mitmproxy): Use mitmproxy 9.0.1 to avoid Rust dependency
mitmproxy 10.x requires mitmproxy_rs which needs Rust compilation.
mitmproxy 9.0.1 is the last pure-Python version that works in Alpine
chroot without /proc mounted.

Bump release to r2.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 07:49:24 +01:00
8ba910c271 fix(mitmproxy): Pin to mitmproxy 10.1.6 to avoid Rust dependency
mitmproxy 10.2+ requires mitmproxy_rs which needs Rust 1.80+, but
Alpine 3.19 only has Rust 1.76. Using mitmproxy 10.1.6 which is the
last pure-Python version without Rust requirements.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 07:49:24 +01:00
f977f488e4 chore(mitmproxy): Update version to 0.4.0
Sync internal package versions for luci-app-mitmproxy and
secubox-app-mitmproxy to 0.4.0.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 07:49:24 +01:00
159e1945b9 fix(mitmproxy): Install Rust toolchain for mitmproxy_rs compilation
mitmproxy 10.2+ requires mitmproxy_rs which needs Rust.
Install rust and cargo from Alpine packages, compile mitmproxy,
then remove build deps to save space.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 07:07:43 +01:00
87e6c53872 fix(mitmproxy): Use Alpine package instead of pip install
mitmproxy_rs now requires Rust compilation which fails in chroot
environment without /proc mounted. Switch to Alpine's pre-built
mitmproxy package from the community repository.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 07:03:23 +01:00
fe222d542c feat(mitmproxy): Add transparent mode, filtering addon, and whitelist
- Add nftables transparent mode support with automatic REDIRECT rules
- Create SecuBox Python filter addon for CDN/Media/Ad tracking
- Add whitelist/bypass configuration for IPs and domains
- Expand UCI config with transparent, whitelist, filtering sections
- Update RPCD backend with new config methods and firewall control
- Update LuCI settings view with all new configuration options
- Add new API methods: firewall_setup, firewall_clear, list management

Features:
- Transparent proxy with nftables integration
- CDN tracking (Cloudflare, Akamai, Fastly, etc.)
- Media streaming tracking (YouTube, Netflix, Spotify)
- Ad/tracker blocking
- IP and domain whitelist bypass

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 06:55:45 +01:00
c99d49739e feat(secubox-app-mitmproxy): Add LXC container support for mitmproxy
- Create mitmproxyctl script with LXC container management
- Alpine Linux rootfs with Python and mitmproxy via pip
- Support for regular, transparent, upstream, and reverse proxy modes
- UCI configuration for proxy_port, web_port, memory_limit, etc.
- procd init script for service management
- Update luci-app-mitmproxy RPCD backend for LXC container status

Ports:
- 8080: Proxy port
- 8081: Web interface (mitmweb)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 06:40:08 +01:00
71ed9ce7e3 fix: Install zstandard 0.23.0 first for musllinux wheel support
The zstandard package required by mitmproxy 8.1.1 doesn't have musllinux
wheels in older versions, causing pip to try compiling from source which
fails without gcc on the router.

Fix: Pre-install zstandard 0.23.0 which has musllinux aarch64 wheels
before installing mitmproxy.

Changes:
- Bump version to 2.1.0
- Revert to pip-based installation (native build requires full toolchain)
- Add zstandard 0.23.0 pre-install step in postinst
- Restore wrapper scripts for mitmproxy/mitmdump/mitmweb

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 18:35:31 +01:00
7f5cb14b96 feat: Rewrite mitmproxy with native OpenWrt build (v10.0.0)
Complete rewrite of secubox-app-mitmproxy to use native OpenWrt packages
instead of pip runtime installation.

New packages created:
- mitmproxy (10.0.0) - Native build from GitHub source
- python3-mitmproxy-rs (0.5.2) - Rust extension with PyO3
- python3-h11 (0.14.0) - HTTP/1.1 protocol
- python3-h2 (4.1.0) - HTTP/2 protocol
- python3-hyperframe (6.0.1) - HTTP/2 framing
- python3-hpack (4.0.0) - HPACK compression
- python3-wsproto (1.2.0) - WebSocket protocol
- python3-aioquic (1.0.0) - QUIC/HTTP3 support
- python3-pylsqpack (0.3.18) - QPACK encoder
- python3-kaitaistruct (0.10) - Binary parsing
- python3-publicsuffix2 (2.20191221) - Domain parsing
- python3-ldap3 (2.9.1) - LDAP support

Changes to secubox-app-mitmproxy:
- Removed pip dependency, now uses native +mitmproxy package
- Removed wrapper scripts (native binaries from mitmproxy package)
- Fixed iptables cleanup to use configured port
- Bumped version to 2.0.0

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 18:28:53 +01:00
22bdf79f66 fix: mitmproxy runtime pip installation for architecture independence
- Switch to runtime pip installation instead of build-time
- Remove complex build dependencies (python3-package.mk)
- Add wrapper scripts for mitmproxy, mitmdump, mitmweb
- Postinst installs mitmproxy==11.1.3 via pip on device
- Supports all architectures with PKGARCH:=all

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 14:51:51 +01:00
6c4257f950 feat: Add mitmproxy HTTPS interception proxy packages
New packages for full URL/cookie/header capture via MITM proxy:

secubox-app-mitmproxy:
- Downloads mitmproxy v11.1.2 binary for aarch64
- Transparent proxy mode with iptables integration
- mitmweb UI on port 8081
- Auto CA certificate generation
- mitmproxyctl CLI management tool

luci-app-mitmproxy:
- SecuBox themed dashboard with red color scheme
- Real-time request capture view
- Top hosts statistics
- CA certificate management
- Full UCI settings interface
- RPCD backend for ubus API

This enables full HTTP/HTTPS inspection including:
- Complete URLs (not just hostnames like nDPId)
- Cookies and headers
- Request/response bodies
- Flow recording for replay

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 14:25:12 +01:00