This document outlines the security features, considerations, and best practices for R3B3L 4F.
The airlock system is a core security feature that controls internet access for R3B3L 4F.
The airlock intercepts all outbound HTTP requests (fetch calls) and blocks them when activated:
// Simplified implementation
window.fetch = async (input, init) => {
if (airlockActive) {
// Block external requests
return new Response(JSON.stringify({
error: 'Airlock active: Internet access is disabled'
}), { status: 403 });
}
// Allow requests to proceed
return originalFetch(input, init);
};- Network Isolation: Prevents unauthorized data exfiltration
- API Protection: Protects API keys from being used without user knowledge
- Offline Operation: Allows operation in air-gapped environments
- User Control: Gives users explicit control over internet access
R3B3L 4F includes protection against potentially dangerous system commands.
Commands are checked against a list of dangerous patterns:
const DANGEROUS_COMMANDS = [
'rm -rf',
'curl | sh',
'wget | sh',
'sudo',
'> /dev/',
'mkfs',
'dd if=',
'format',
':(){:|:&};:',
'chmod -R 777 /',
'mv /* /dev/null'
];
const isDangerousCommand = (command) => {
return DANGEROUS_COMMANDS.some(dangerousCmd => command.includes(dangerousCmd));
};When a dangerous command is detected, it requires explicit confirmation:
if (isDangerousCommand(command)) {
const confirmationToken = generateConfirmationToken(command);
return {
requiresConfirmation: true,
confirmationToken,
message: `This command is potentially dangerous. Confirm execution?`
};
}- Accidental Execution Prevention: Prevents accidental execution of harmful commands
- Deliberate Confirmation: Requires explicit confirmation for risky operations
- Audit Trail: Creates a record of confirmed dangerous commands
R3B3L 4F includes measures to protect API keys and sensitive credentials.
- API keys are stored in environment variables, not in the code
- Keys are never exposed in client-side code
- The
.envfile is excluded from version control via.gitignore - In production, keys are stored in the deployment platform's environment variables
- Credential Protection: Prevents API key exposure
- Least Privilege: Keys are only accessible where needed
- Revocation: Keys can be easily rotated without code changes
R3B3L 4F implements a Content Security Policy to prevent various attacks.
The CSP header restricts the sources of content that can be loaded:
Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self' https://api.openai.com https://*.supabase.co;
- XSS Protection: Prevents execution of injected scripts
- Data Exfiltration Prevention: Restricts where data can be sent
- Resource Integrity: Ensures resources come from trusted sources
Proper API key management is critical for security:
- Never commit API keys to version control
- Use environment variables for all sensitive credentials
- Rotate keys regularly
- Use the principle of least privilege - only grant necessary permissions
- Monitor API usage for unusual patterns
Data stored in localStorage has security implications:
- Don't store sensitive information in localStorage
- Sanitize user input before storing
- Be aware that localStorage is accessible to any script on the same origin
- Consider encrypting sensitive data before storing
When executing system commands:
- Always validate and sanitize input
- Run with least privilege
- Implement timeouts to prevent long-running commands
- Capture and validate output before displaying
- Restrict command execution to necessary functionality
- Keep dependencies updated to patch security vulnerabilities
- Implement input validation for all user inputs
- Use HTTPS for all external communications
- Follow the principle of least privilege
- Implement proper error handling that doesn't expose sensitive information
- Use Content Security Policy to restrict resource loading
- Regularly audit the codebase for security issues
- Keep your API keys secure and don't share them
- Use the airlock feature when not actively requiring internet access
- Be cautious with dangerous commands
- Regularly check for updates to the application
- Be aware of the data being stored in your browser
When deploying to Netlify:
- Use environment variables for all sensitive information
- Enable branch deploy controls to prevent unauthorized deployments
- Configure proper headers including CSP
- Enable HTTPS and HSTS
- Set up proper access controls for the Netlify site
When self-hosting:
- Use HTTPS with valid certificates
- Implement proper firewall rules
- Keep the server updated with security patches
- Use a reverse proxy like Nginx with security configurations
- Implement rate limiting to prevent abuse
Be aware of these security limitations:
- Browser-based security can be bypassed by determined attackers
- The airlock only controls fetch requests, not all network access
- localStorage is not secure for highly sensitive information
- Command execution is inherently risky in any application
If you discover a security vulnerability:
- Do not disclose publicly until it has been addressed
- Report the issue to the repository maintainers
- Provide detailed information about the vulnerability
- Allow time for a fix before public disclosure
Regular security auditing is recommended:
- Dependency scanning for known vulnerabilities
- Static code analysis to identify potential issues
- Manual code review focusing on security-critical areas
- Penetration testing to identify exploitable vulnerabilities
Planned security improvements:
- End-to-end encryption for sensitive data
- Two-factor authentication for access control
- Enhanced sandboxing for command execution
- Improved airlock with finer-grained controls
- Security logging and alerting for suspicious activities