Skip to content

feat: segmentation policy checks, dual-stack exposure, signed evidence, unknown-service grouping - #16

Merged
NycolazSec merged 1 commit into
mainfrom
feat/audit-features
Oct 10, 2026
Merged

NycolazSec merged 1 commit into
mainfrom
feat/audit-features

Conversation

@NycolazSec

Copy link
Copy Markdown
Owner

Summary

Four audit features for verifying one's own network:

  • tcpcat policy check <policy.yaml> --from <vantage>: segmentation testing as code. A YAML policy declares zones and, per vantage point, which TCP ports may (allow) or must (require) be reachable. Checked with TCP connect probes (no root). Exit 0 compliant / 1 violation / 2 error, with JSON and SARIF reports, so it can gate CI after a firewall change. tcpcat policy matrix merges reports from several vantages. Unknown policy keys are rejected (a typo can't turn a rule into "allow nothing"); --scope-file is honored.
  • --dual-stack: scans the DNS-published IPv6 address of each IPv4 target on the same ports and reports ports open on IPv6 only — the usual sign of firewall rules written for IPv4 alone. tcpcat previously scanned only the IPv4 address of dual-stack names. New dual_stack JSON field and DUAL-STACK-IPV6-ONLY SARIF rule.
  • --evidence <file> / --evidence-key, tcpcat evidence keygen|verify, tcpcat replay: a bundle of every open port (when, from where, how it answered; secrets redacted) with a SHA-256 digest and an optional Ed25519 signature (standard PKCS#8/PKIX PEM). replay refuses a tampered bundle, re-probes each finding and exits 0 only when all are fixed.
  • Unknown-service grouping (with -sV): unrecognized banners are normalized and grouped across hosts, each group printed with a suggested signature; --fingerprints-out exports groups without addresses or raw banners.

Other changes: subcommands are dispatched before the scanner's flag parsing; SARIF locations bracket IPv6 addresses (tcp://[::1]:22). New dependency: go.yaml.in/yaml/v3 (the maintained YAML fork).

Checklist

  • I read CONTRIBUTING.md
  • gofmt -l . produces no output
  • go vet ./... passes
  • go test -race ./... passes
  • I added/updated tests for behavioral changes
  • I updated README.md/docs/ for user-facing changes
  • This change preserves the authorized-use guidance in NOTICE.md and does not add functionality whose primary purpose is unauthorized access, disruption, credential theft, persistence, or concealment of unlawful activity

Test plan

  • Unit tests for the four new packages (internal/policy, internal/dualstack, internal/evidence, internal/fingerprint).
  • Full suite with -race, go vet, golangci-lint (0 issues) and gosec run in a Linux container; also run on macOS.
  • End-to-end against local listeners:
    • policy: an extra open port and a missing required port are both reported, exit codes 0/1/2, JSON/SARIF/matrix output checked;
    • dual-stack: a service bound to ::1 only is flagged as IPv6-only for localhost;
    • evidence/replay: signed bundle verified, API key redacted, replay reports STILL OPEN then FIXED as services are stopped, a one-byte edit of the bundle is rejected;
    • grouping: the same unknown banner on 127.0.0.1 and ::1 is grouped with a working suggested regex, and the export contains no address.

…e, unknown-service grouping

Four audit features aimed at verifying one's own network:

- `tcpcat policy check <policy.yaml> --from <vantage>`: segmentation testing
  as code. A YAML policy declares zones and, per vantage, which TCP ports may
  (allow) or must (require) be reachable. Checked with connect probes; exit
  1 on violation, JSON + SARIF reports. `tcpcat policy matrix` merges the
  reports of several vantages. Unknown policy keys are rejected.

- `--dual-stack`: scan the DNS-published IPv6 address of each IPv4 target on
  the same ports and report ports open on IPv6 only (firewall rules written
  for IPv4 alone). New `dual_stack` JSON field, DUAL-STACK-IPV6-ONLY SARIF
  rule; the IPv6 leg uses TCP connect since raw scans only build IPv4.

- `--evidence <file>` / `--evidence-key`: bundle of every open port (when,
  from where, how it answered) with secrets redacted, a SHA-256 digest and an
  optional Ed25519 signature. `tcpcat evidence keygen|verify` and
  `tcpcat replay`, which refuses a tampered bundle, re-probes each finding
  and exits 0 only when all are fixed.

- With -sV, unrecognized services are grouped across hosts by normalized
  banner and printed with a suggested signature; `--fingerprints-out`
  exports the groups without addresses or raw banners.

Subcommands are dispatched before the scanner's flag parsing. SARIF
locations now bracket IPv6 addresses. Adds go.yaml.in/yaml/v3.
@NycolazSec
NycolazSec merged commit 929f04f into main Oct 10, 2026
3 of 4 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant