Skip to content

feat(kernel): implement containerized PDP with tiered security scanning#39

Open
eddymontana wants to merge 12 commits into
c2siorg:mainfrom
eddymontana:main
Open

feat(kernel): implement containerized PDP with tiered security scanning#39
eddymontana wants to merge 12 commits into
c2siorg:mainfrom
eddymontana:main

Conversation

@eddymontana
Copy link
Copy Markdown

This PR finalizes the Phase 2 architecture for the Agentic Cognitive Firewall. It introduces a high-performance Go-based PDP (Policy Decision Point) and a Python PEP (Policy Enforcement Point) with a focus on low-latency security scanning.

Note: This is a fresh submission that replaces #17. It preserves Phase 1 logic while introducing Phase 2 enhancements, addresses prior feedback regarding project structure, and removes all compiled binaries from version control.

🛠️ Key Technical Implementations

  • Multi-Layer Kernel: Implemented tiered scanning—L1 Hygiene (Base64/Normalization) and L2 Lexical (Aho-Corasick) with ~0.5ms overhead.

  • Secure Transport: Windows Named Pipe and Unix Domain Socket support with HMAC-SHA256 signing and nonce-based replay protection.

  • Containerization: Added Dockerfile and docker-compose.yml for automated sidecar deployment.

  • Phase 3 Alignment: Updated prerequisites (Go 1.25+) and README documentation to match the project's roadmap.

🧪 Validation
Verified BLOCK signals for SQL injection and prompt injection attack vectors.

  • Confirmed the sidecar remains stable under sequential header-first reads.

  • 100% pass rate on internal/kernel unit tests.

  • Why this version is better:

@VibhorGautam
Copy link
Copy Markdown

went through the diff, few notes from the kernel side

  1. the PR body mentions "Windows Named Pipe and Unix Domain Socket support" but cmd/sidecar/main.go only calls winio.ListenPipe against a \\.\pipe\... path. Microsoft/go-winio's pipe API is windows-only (the package uses build tags to exclude non-windows), so this won't compile on linux/macos let alone run. either add main_unix.go with a net.Listen("unix", path) variant gated by build tags, or dispatch on runtime.GOOS

  2. hygiene.go has a base64 false-positive floor. any 4-char ASCII slice made of base64 chars decodes cleanly (abcd → 3 random bytes, nil err), so err == nil && len(decoded) > 0 fires on benign input and the lexical scanner ends up running on binary garbage. cheap heuristics that help: minimum source length (≥12), require padding actually present, or check decoded bytes are mostly printable before trusting the unwrap

  3. the feat(kernel): finalize Phase 2 architecture with Aho-Corasick & HMAC transport #17 thread called out d.a.n m.o.d.e obfuscation as the phase 2 regex target. current scanner.go has dan\s+mode which still won't hit the dot-separated variant. worth a test row + either preprocessing the input (strip non-word chars before scan) or loosening the pattern

  4. docker-compose.yml and sidecar/Dockerfile both have a UTF-8 BOM on line 1 (the  char before services: / FROM). some compose versions reject it silently. also go build -o sidecar ./cmd/sidecar/main.go should be ./cmd/sidecar so the whole package compiles and not just main.go

smaller stuff, non-blocking:

  • conn.Read(buf) drops err and uses a fixed 1024 buffer, larger payloads truncate silently. the existing sidecar has length-prefix framing worth reusing
  • internal/kernel/hooks/{context,memory,prompt,tool}.go are 0-byte files, probably easier to not commit till they have content
  • build.bat at repo root is empty too

@eddymontana
Copy link
Copy Markdown
Author

Thanks for the thorough review, @VibhorGautam. I've pushed a series of commits to address the kernel-side notes:

  • Platform Parity: Switched from a single main.go to build-tagged main_windows.go and main_unix.go. The sidecar now correctly dispatches to UDS on Linux/macOS and Named Pipes on Windows.

  • Base64 Heuristics: Added a printability check and a minimum length floor to the hygiene scanner to prevent the binary-garbage false positives you mentioned.

  • Regex Obfuscation: Loosened the lexical patterns to catch dot-separated and whitespace-obfuscated variants of the target injection strings.

  • Build/Env Polish: Fixed the UTF-8 BOM on the Docker/Compose files, updated the Dockerfile to build the full package path, and purged the 0-byte placeholder files.

Updated the README to reflect the new cross-platform build commands. Ready for another look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants