Skip to content

Conversation

f0ssel
Copy link
Collaborator

@f0ssel f0ssel commented Sep 9, 2025

Changes

  • Sudo support: Subprocess runs as original user instead of root when using sudo jail
  • Environment restoration: Restores HOME, USER, LOGNAME for proper tool functionality
  • Certificate handling: Stores CA certs in user's directory with correct ownership
  • Audit system: Structured logging for HTTP/HTTPS requests
  • CLI refactoring: Modular CLI package with better error handling
  • Rules engine: Simplified boolean allow/deny logic

Usage

# Before: subprocess runs as root
sudo jail --allow "github.com" -- whoami  # Returns "root"

# After: subprocess runs as original user
sudo jail --allow "github.com" -- whoami  # Returns your username

Fixes the core issue where tools couldn't access user configs/credentials when jail was run with sudo.

This implements a complete HTTP/HTTPS traffic monitoring and filtering
solution with transparent proxy capabilities and proper sudo handling.

Key Features:

## Audit System
- Add comprehensive audit package for request logging
- Support for structured logging with configurable levels
- HTTP request to audit request conversion with full metadata
- Extensive test coverage for all audit functionality

## CLI Refactoring
- Refactor main.go into modular CLI package
- Improved command-line argument handling
- Better error handling and logging setup
- Cleaner separation of concerns

## Rules Engine Improvements
- Simplify rules to boolean allow/deny logic
- Remove complex Action types for cleaner implementation
- Enhanced rule matching with method and URL pattern support
- Comprehensive test coverage for rule evaluation

## Proxy Enhancements
- Integrate audit logging into proxy request handling
- Improved error handling and logging
- Better request/response processing

## Sudo Support (Critical Feature)
- **Privilege Dropping**: Subprocess runs as original user instead of root
- **Environment Restoration**: Restore HOME, USER, LOGNAME for original user
- **Certificate Management**: Store CA certificates in user's directory with proper ownership
- **Network Isolation**: Maintain jail group membership for proper traffic routing
- **Cross-Platform**: Works on both Linux (namespaces) and macOS (groups)

## TLS Certificate Improvements
- Use original user's home directory for certificate storage when running under sudo
- Proper directory ownership to ensure subprocess can access certificates
- Enhanced certificate path resolution

## Network Jail Enhancements
- Linux: Enhanced namespace handling with proper privilege dropping
- macOS: Improved group-based isolation with user privilege restoration
- Maintain network isolation while running as correct user identity

This implementation provides a complete solution for HTTP/HTTPS traffic
monitoring with proper user identity preservation when used with sudo.

Tested on both Linux and macOS platforms.

Co-authored-by: f0ssel <[email protected]>
@blink-so blink-so bot force-pushed the blink/httpjail-go-implementation branch from 780f2b1 to db3652e Compare September 9, 2025 20:49
@blink-so blink-so bot changed the title Blink/httpjail go implementation feat: implement HTTP/HTTPS jail with Go proxy and sudo support Sep 9, 2025
@f0ssel f0ssel requested a review from bcpeinhardt September 9, 2025 21:03
@f0ssel f0ssel changed the title feat: implement HTTP/HTTPS jail with Go proxy and sudo support feat: implement better sudo support Sep 9, 2025
@f0ssel
Copy link
Collaborator Author

f0ssel commented Sep 9, 2025

Still a few crazy if statements in here to cleanup

@f0ssel f0ssel merged commit e4bff6a into main Sep 9, 2025
4 checks passed
@f0ssel f0ssel deleted the blink/httpjail-go-implementation branch September 16, 2025 15:53
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.

1 participant