algo/roles/privacy/README.md
Dan Guido 454faa96b1
fix: Prevent sensitive information from being logged (#14779)
* fix: Add no_log to tasks handling sensitive information

- Add no_log: true to OpenSSL commands that contain passwords/passphrases
- Add no_log: true to WireGuard key generation commands
- Add no_log: true to password/CA password generation tasks
- Add no_log: true to AWS credential handling tasks
- Add no_log: true to QR code generation that contains full configs

This prevents sensitive information like passwords, private keys, and
WireGuard configurations from being logged to syslog/journald.

Fixes #1617

* feat: Comprehensive privacy enhancements

- Add no_log directives to all cloud provider credential handling
- Set privacy-focused defaults (StrongSwan logging disabled, DNSCrypt syslog off)
- Implement privacy role with log rotation, history clearing, and log filtering
- Add Privacy Considerations section to README
- Make all privacy features configurable and enabled by default

This update significantly reduces Algo's logging footprint to enhance user privacy
while maintaining the ability to enable logging for debugging when needed.

* docs: Move privacy documentation from README to FAQ

- Remove Privacy Considerations section from README
- Add expanded 'Does Algo support zero logging?' question to FAQ
- Better placement alongside existing logging/monitoring questions
- More detailed explanation of privacy features and limitations

* fix: Remove invalid 'bool' filter from Jinja2 template

The privacy-monitor.sh.j2 template was using '| bool' which is not a valid
Jinja2 filter. The 'bool' is a built-in Python function, not a Jinja2 filter.

Fixed by removing the '| bool' filter and directly outputting the boolean
variables as they will be rendered correctly by Jinja2.

This resolves the template syntax error that was causing CI tests to fail:
"No filter named 'bool'" error in privacy monitoring script template.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix YAML linting issues in privacy role

* Fix linting warnings: shellcheck and ansible-lint issues

- Fixed all shellcheck warnings in test scripts:
  - Quoted variables to prevent word splitting
  - Replaced A && B || C constructs with proper if-then-else
  - Changed unused loop variable to _
  - Added shellcheck directives for FreeBSD rc.d script

- Fixed ansible-lint risky-file-permissions warnings:
  - Added explicit file permissions for sensitive files (mode 0600)
  - Added permissions for config files and certificates (mode 0644)
  - Set proper permissions for directories (mode 0755)

- Fixed yamllint compatibility with ansible-lint:
  - Added required octal-values configuration
  - Quoted all octal mode values to prevent YAML misinterpretation
  - Added comments-indentation: false as required

All tests pass and functionality remains unchanged.

* Remove algo.egg-info from version control

This directory is generated by Python package tools (pip/setuptools) and
should not be tracked in git. It's already listed in .gitignore but was
accidentally committed. The directory contains build metadata that is
regenerated when the package is installed.

* Restructure privacy documentation for clarity

- Simplified FAQ entry to be concise with link to README for details
- Added comprehensive Privacy and Logging section to README
- Clarified what IS logged by default vs what is not
- Explained two separate privacy settings (strongswan_log_level and privacy_enhancements_enabled)
- Added clear debugging instructions (need to change both settings)
- Removed confusing language about "enabling additional features"
- Made documentation more natural and less AI-generated sounding

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix Ubuntu 22.04 iptables deployment issues and simplify config.cfg

Issues fixed:
1. Added base 'iptables' package to batch installation list (was missing, only iptables-persistent was included)
2. Fixed alternatives configuration for Ubuntu 22.04+ - only configure main iptables/ip6tables alternatives, not save/restore (they're handled as slaves)

Config.cfg improvements:
- Reduced from 308 to 198 lines (35% reduction)
- Moved privacy settings above "Advanced users only" line for better accessibility
- Clarified algo_no_log is for Ansible output, not server privacy
- Simplified verbose comments throughout
- Moved experimental performance options to commented section at end
- Better organized into logical sections

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add privacy features to README and improve feature descriptions

- Added privacy-focused feature bullet highlighting minimal logging and privacy enhancements
- Simplified IKEv2 bullet (removed redundant platform list)
- Updated helper scripts description to be more comprehensive
- Specified Ubuntu 22.04 LTS and automatic security updates
- Made feature list more concise and accurate

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix logrotate duplicate entries error in privacy role

The privacy role was creating logrotate configs that duplicated the default
Ubuntu rsyslog logrotate rules, causing deployment failures with errors like
'duplicate log entry for /var/log/syslog'.

Changes:
- Disable default rsyslog logrotate config before applying privacy configs
- Consolidate system log rotation into single config file
- Add missingok flag to handle logs that may not exist on all systems
- Remove forced immediate rotation that was triggering the error

This ensures privacy-enhanced log rotation works without conflicts.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix 'history: not found' error in privacy role

The 'history -c' command was failing because history is a bash built-in
that doesn't exist in /bin/sh (Ubuntu's default shell for scripts).

Changes:
- Removed the 'Clear current session history' task since it's ineffective
  in Ansible context (each task runs in a new shell)
- History files are already cleared by the existing file removal tasks
- Added explanatory comment about why session history clearing is omitted

This fixes the deployment failure while maintaining all effective history
clearing functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix BPF JIT sysctl error in privacy role

The net.core.bpf_jit_enable sysctl parameter was failing on some systems
because BPF JIT support is not available in all kernel configurations.

Changes:
- Separated BPF JIT setting into its own task with ignore_errors
- Made BPF JIT disabling optional since it's not critical for privacy
- Added explanatory comments about kernel support variability
- Both runtime sysctl and persistent config now handle missing parameter

This allows deployments to succeed on systems without BPF JIT support
while still applying the setting where available.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-17 15:58:19 -04:00

6.5 KiB

Privacy Enhancements Role

This Ansible role implements additional privacy enhancements for Algo VPN to minimize server-side traces of VPN usage and reduce log retention. These measures help protect user privacy while maintaining system security.

Features

1. Aggressive Log Rotation

  • Configures shorter log retention periods (default: 7 days)
  • Implements more frequent log rotation
  • Compresses rotated logs to save space
  • Automatically cleans up old log files

2. History Clearing

  • Clears bash/shell history after deployment
  • Disables persistent command history for system users
  • Clears temporary files and caches
  • Sets up automatic history clearing on user logout

3. VPN Log Filtering

  • Filters out VPN connection logs from rsyslog
  • Excludes WireGuard and StrongSwan messages from persistent storage
  • Filters kernel messages related to VPN traffic
  • Optional filtering of authentication logs (use with caution)

4. Automatic Cleanup

  • Daily/weekly/monthly cleanup of old logs and temporary files
  • Package cache cleaning
  • Configurable retention policies
  • Optional shutdown cleanup for extreme privacy

5. Advanced Privacy Settings

  • Reduced kernel log verbosity
  • Disabled successful SSH connection logging (optional)
  • Volatile systemd journal storage
  • Privacy monitoring script

Configuration

All privacy settings are configured in config.cfg under the "Privacy Enhancements" section:

# Enable/disable all privacy enhancements
privacy_enhancements_enabled: true

# Log rotation settings
privacy_log_rotation:
  max_age: 7              # Days to keep logs
  max_size: 10            # Max size per log file (MB)
  rotate_count: 3         # Number of rotated files to keep
  compress: true          # Compress rotated logs
  daily_rotation: true    # Force daily rotation

# History clearing
privacy_history_clearing:
  clear_bash_history: true
  clear_system_history: true
  disable_service_history: true

# Log filtering
privacy_log_filtering:
  exclude_vpn_logs: true
  exclude_auth_logs: false    # Use with caution
  filter_kernel_vpn_logs: true

# Automatic cleanup
privacy_auto_cleanup:
  enabled: true
  frequency: "daily"          # daily, weekly, monthly
  temp_files_max_age: 1
  clean_package_cache: true

# Advanced settings
privacy_advanced:
  disable_ssh_success_logs: false
  reduce_kernel_verbosity: true
  clear_logs_on_shutdown: false  # Extreme measure

Security Considerations

Safe Settings (Default)

  • exclude_vpn_logs: true - Safe, only filters VPN-specific messages
  • clear_bash_history: true - Safe, improves privacy without affecting security
  • reduce_kernel_verbosity: true - Safe, reduces noise in logs

Use With Caution

  • exclude_auth_logs: true - Reduces security logging, makes incident investigation harder
  • disable_ssh_success_logs: true - Removes audit trail for successful connections
  • clear_logs_on_shutdown: true - Extreme measure, makes debugging very difficult

Files Created

Configuration Files

  • /etc/logrotate.d/99-privacy-enhanced - Main log rotation config
  • /etc/logrotate.d/99-auth-privacy - Auth log rotation
  • /etc/logrotate.d/99-kern-privacy - Kernel log rotation
  • /etc/rsyslog.d/49-privacy-vpn-filter.conf - VPN log filtering
  • /etc/rsyslog.d/48-privacy-kernel-filter.conf - Kernel log filtering
  • /etc/rsyslog.d/47-privacy-auth-filter.conf - Auth log filtering (optional)
  • /etc/rsyslog.d/46-privacy-ssh-filter.conf - SSH log filtering (optional)
  • /etc/rsyslog.d/45-privacy-minimal.conf - Minimal logging config

Scripts

  • /usr/local/bin/privacy-auto-cleanup.sh - Automatic cleanup script
  • /usr/local/bin/privacy-log-cleanup.sh - Initial log cleanup
  • /usr/local/bin/privacy-monitor.sh - Privacy status monitoring
  • /etc/bash.bash_logout - History clearing on logout

Systemd Services

  • /etc/systemd/system/privacy-shutdown-cleanup.service - Shutdown cleanup (optional)

Usage

Enable Privacy Enhancements

Privacy enhancements are enabled by default. To disable them:

privacy_enhancements_enabled: false

Run Specific Privacy Tasks

You can run specific privacy components using tags:

# Run only log rotation setup
ansible-playbook server.yml --tags privacy-logs

# Run only history clearing
ansible-playbook server.yml --tags privacy-history

# Run only log filtering
ansible-playbook server.yml --tags privacy-filtering

# Run only cleanup tasks
ansible-playbook server.yml --tags privacy-cleanup

# Run all privacy enhancements
ansible-playbook server.yml --tags privacy

Monitor Privacy Status

Check the status of privacy enhancements:

sudo /usr/local/bin/privacy-monitor.sh

Manual Cleanup

Run manual cleanup:

sudo /usr/local/bin/privacy-auto-cleanup.sh

Debugging

If you need to debug VPN issues, temporarily disable privacy enhancements:

  1. Set privacy_enhancements_enabled: false in config.cfg
  2. Re-run the deployment: ./algo
  3. Debug your issues with full logging
  4. Re-enable privacy enhancements when done

Alternatively, disable specific features:

  • Set exclude_vpn_logs: false to see VPN connection logs
  • Set reduce_kernel_verbosity: false for full kernel logging
  • Check /var/log/privacy-cleanup.log for cleanup operation logs

Impact on System

Positive Effects

  • Improved user privacy
  • Reduced disk usage from logs
  • Faster log searches
  • Reduced attack surface

Potential Drawbacks

  • Limited debugging information
  • Shorter audit trail
  • May complicate troubleshooting
  • Could hide security incidents

Compatibility

  • Ubuntu 22.04: Fully supported
  • FreeBSD: Limited support (log rotation and history clearing only)
  • Other distributions: May require adaptation

Best Practices

  1. Start Conservative: Use default settings initially
  2. Test Thoroughly: Verify VPN functionality after enabling privacy features
  3. Monitor Logs: Check that essential security logs are still being captured
  4. Document Changes: Keep track of privacy settings for troubleshooting
  5. Regular Reviews: Periodically review privacy settings and their effectiveness

Privacy vs. Security Balance

This role aims to balance privacy with security by:

  • Keeping security-critical logs (authentication failures, system errors)
  • Filtering only VPN-specific operational logs
  • Providing granular control over what gets filtered
  • Maintaining essential audit trails while reducing VPN usage traces

For maximum privacy, consider running your own log analysis before enabling aggressive filtering options.