Skip to content

Security: dimensigon/aishell

Security

SECURITY.md

Security Policy

Table of Contents

Supported Versions

We actively maintain security updates for the following versions:

Version Supported End of Life
1.0.x TBD
< 1.0 N/A

Update Policy

  • Critical Security Issues: Patched within 48 hours
  • High Severity Issues: Patched within 7 days
  • Medium/Low Severity: Included in next minor release

Reporting a Vulnerability

How to Report

DO NOT open public GitHub issues for security vulnerabilities.

Instead, report security vulnerabilities to: security@ai-shell.dev

What to Include

Please provide the following information:

  1. Description: Detailed description of the vulnerability
  2. Impact: Potential impact and severity assessment
  3. Reproduction: Step-by-step instructions to reproduce the issue
  4. Environment: Version, OS, configuration details
  5. Proof of Concept: Code or commands demonstrating the vulnerability (if applicable)
  6. Suggested Fix: Your recommendations for remediation (if available)

Response Timeline

  • Initial Response: Within 24 hours
  • Triage & Assessment: Within 72 hours
  • Status Updates: Every 7 days until resolution
  • Fix Timeline: Based on severity (see above)

Disclosure Policy

We follow coordinated disclosure:

  1. Report Received: We acknowledge your report
  2. Investigation: We investigate and validate the issue
  3. Fix Development: We develop and test a fix
  4. Release: We release the fix to supported versions
  5. Public Disclosure: 30 days after release (or as agreed)

Bug Bounty

We currently do not offer a bug bounty program but greatly appreciate responsible disclosure.

Security Features

1. SQL Injection Prevention

AI-Shell includes active SQL injection prevention:

// All queries are automatically analyzed for injection risks
const riskLevel = sqlSecurityAnalyzer.analyzeRisk(query);
if (riskLevel === 'CRITICAL') {
  throw new SecurityError('SQL injection risk detected');
}

Features:

  • Pattern-based injection detection
  • Prepared statement enforcement
  • Query parameterization
  • Input sanitization
  • Real-time risk assessment

2. Encryption

Data at Rest

  • Algorithm: AES-256-GCM
  • Key Derivation: PBKDF2 with 100,000 iterations
  • Salt: Unique random salt per encryption
// Vault credentials are encrypted by default
await vault.store('db-password', password, { encrypt: true });

Data in Transit

  • TLS 1.2+ required for all connections
  • Support for custom CA certificates
  • Certificate pinning available

3. Authentication & Authorization

Role-Based Access Control (RBAC)

// Define roles and permissions
const roles = {
  admin: ['read', 'write', 'delete', 'admin'],
  developer: ['read', 'write'],
  analyst: ['read']
};

Built-in Roles:

  • admin: Full access to all operations
  • developer: Read/write access, no administrative functions
  • analyst: Read-only access
  • viewer: Limited read access

Session Management

  • Secure session tokens (256-bit random)
  • Configurable session timeout (default: 1 hour)
  • Automatic session invalidation
  • Concurrent session limits

4. Audit Logging

Comprehensive audit trail for all operations:

// All database operations are logged
{
  timestamp: '2025-10-28T12:00:00Z',
  user: 'admin',
  operation: 'query',
  query: 'SELECT * FROM users',
  result: 'success',
  affectedRows: 42,
  ip: '192.168.1.100',
  sessionId: 'abc123'
}

Logged Events:

  • Authentication attempts (success/failure)
  • Database connections/disconnections
  • Query executions
  • Configuration changes
  • Permission modifications
  • Error events
  • Security alerts

5. Input Validation

All user input is validated and sanitized:

// Schema-based validation
const validation = {
  connectionString: /^(postgres|mysql|mongodb|redis):\/\/.+$/,
  queryTimeout: { type: 'number', min: 0, max: 300000 },
  poolSize: { type: 'number', min: 1, max: 100 }
};

6. PII Detection & Redaction

Automatic detection and redaction of sensitive data:

// PII is automatically detected and can be redacted
const piiDetector = new PIIDetector();
const redacted = piiDetector.redact(data, {
  email: true,
  ssn: true,
  creditCard: true,
  phone: true
});

Detected PII Types:

  • Email addresses
  • Social Security Numbers (SSN)
  • Credit card numbers
  • Phone numbers
  • IP addresses (optional)
  • Custom patterns

7. Rate Limiting

Prevent abuse and DoS attacks:

// Rate limiting configuration
const rateLimiter = {
  windowMs: 15 * 60 * 1000, // 15 minutes
  maxRequests: 100,
  maxConcurrent: 10
};

8. Secure Credential Storage (Vault)

Encrypted credential management:

# Store credentials securely
ai-shell vault-add prod-db "password123" --encrypt

# Credentials are encrypted with AES-256
# Master key is derived from system keychain or environment variable

Vault Features:

  • AES-256 encryption
  • Automatic key rotation
  • Secure key derivation
  • Integration with system keychain
  • Backup and restore capabilities

Best Practices

For Users

1. Credential Management

DO:

# Use vault for credentials
ai-shell vault-add production "secure-password" --encrypt

# Use environment variables
export DATABASE_URL="postgres://..."
ai-shell connect $DATABASE_URL

# Use connection strings without inline passwords
ai-shell connect postgres://user@localhost:5432/db
# (prompts for password securely)

DON'T:

# Never hardcode credentials in scripts
ai-shell connect postgres://user:password@localhost/db  #

# Never commit .env files with secrets
# Never share connection strings in logs/screenshots

2. Network Security

Recommendations:

  • Use SSL/TLS for all database connections
  • Restrict network access to databases (firewall rules)
  • Use VPN for remote database access
  • Enable connection encryption:
# config.yaml
databases:
  production:
    ssl:
      enabled: true
      rejectUnauthorized: true
      ca: /path/to/ca-cert.pem

3. Least Privilege

Grant minimum required permissions:

// Create read-only database users for analysis
CREATE USER analyst WITH PASSWORD 'secure-password';
GRANT SELECT ON ALL TABLES IN SCHEMA public TO analyst;

// Use separate credentials for different environments
ai-shell connect postgres://analyst@prod/db --name prod-readonly

4. Query Safety

Safe Practices:

# Always use --dry-run for destructive operations
ai-shell execute "DELETE FROM users" --dry-run

# Review explain plans before execution
ai-shell explain "UPDATE users SET status = 'inactive'"

# Use transactions for data modifications
BEGIN;
UPDATE users SET email = 'new@email.com' WHERE id = 1;
-- Review changes
ROLLBACK;  -- or COMMIT

5. Session Management

# Start named sessions for audit trail
ai-shell session start "data-migration-2025-10-28"

# End sessions when done
ai-shell session end

# Review session history
ai-shell session list

For Developers

1. Secure Code Practices

// ✅ GOOD: Use parameterized queries
const result = await db.query(
  'SELECT * FROM users WHERE id = $1',
  [userId]
);

// ❌ BAD: String concatenation
const result = await db.query(
  `SELECT * FROM users WHERE id = ${userId}`
);

2. Error Handling

// ✅ GOOD: Safe error messages
try {
  await db.connect();
} catch (error) {
  logger.error('Database connection failed', {
    error: error.message
  });
  throw new Error('Unable to connect to database');
}

// ❌ BAD: Exposing internals
catch (error) {
  throw new Error(`Connection failed: ${connection.password}`);
}

3. Input Validation

// ✅ GOOD: Validate all inputs
function validateQuery(query: string): void {
  if (!query || typeof query !== 'string') {
    throw new ValidationError('Invalid query');
  }
  if (query.length > 10000) {
    throw new ValidationError('Query too long');
  }
  // Additional validation...
}

4. Dependency Management

# Regular security audits
npm audit
npm audit fix

# Keep dependencies updated
npm update

# Review dependency licenses
npm run license-checker

Compliance

GDPR (General Data Protection Regulation)

AI-Shell supports GDPR compliance through:

  1. Data Minimization: Only collect necessary data
  2. Right to Erasure: Support for data deletion
  3. Data Portability: Export data in standard formats
  4. Audit Logging: Comprehensive access logs
  5. Encryption: Data at rest and in transit

GDPR Features:

// PII detection and redaction
const piiDetector = new PIIDetector();
piiDetector.scan(data);

// Data export (right to portability)
ai-shell query "SELECT * FROM users WHERE id = $1" --format json

// Data deletion (right to erasure)
ai-shell execute "DELETE FROM users WHERE id = $1" --audit

SOX (Sarbanes-Oxley Act)

Compliance support for financial data:

  1. Audit Trails: All operations logged with timestamps
  2. Access Controls: RBAC and authentication
  3. Data Integrity: Transaction support
  4. Change Management: Version control for queries
# SOX-compliant audit log
ai-shell audit-show --user admin --from 2025-10-01

# Immutable audit logs
# Logs are append-only and cryptographically signed

HIPAA (Health Insurance Portability and Accountability Act)

For healthcare data:

  1. Encryption: AES-256 for PHI
  2. Access Logs: Track all PHI access
  3. Authentication: Strong user authentication
  4. Automatic Logoff: Session timeout
# HIPAA configuration
security:
  encryption:
    enabled: true
    algorithm: aes-256-gcm
  sessionTimeout: 900000  # 15 minutes
  audit:
    enabled: true
    immutable: true

PCI DSS (Payment Card Industry Data Security Standard)

For payment data:

  1. Encryption: Strong cryptography
  2. Access Control: Least privilege
  3. Monitoring: Real-time monitoring
  4. Testing: Regular security testing

Note: AI-Shell should NOT be used to store credit card data directly. Use tokenization services.

Security Modules

AI-Shell includes 15 security modules:

1. Vault Module

  • Secure credential storage
  • AES-256 encryption
  • Key derivation with PBKDF2

2. Encryption Module

  • AES-256-GCM encryption
  • Secure random number generation
  • Key management

3. RBAC Module

  • Role-based access control
  • Permission management
  • User/group management

4. Audit Module

  • Comprehensive logging
  • Tamper-evident logs
  • Log analysis

5. SQL Injection Prevention

  • Pattern detection
  • Risk analysis
  • Query sanitization

6. PII Detection

  • Regex-based detection
  • Machine learning detection
  • Custom pattern support

7. Rate Limiting

  • Request rate limiting
  • Concurrent connection limits
  • Burst protection

8. Input Validation

  • Schema validation
  • Type checking
  • Sanitization

9. Session Management

  • Secure session tokens
  • Timeout management
  • Session tracking

10. Connection Security

  • TLS enforcement
  • Certificate validation
  • Secure protocols

11. Authentication

  • Password hashing (bcrypt)
  • Multi-factor authentication (planned)
  • SSO integration (planned)

12. Authorization

  • Permission checking
  • Resource-based access
  • Dynamic policies

13. Error Handling

  • Safe error messages
  • Error logging
  • Stack trace sanitization

14. Secure Configuration

  • Configuration validation
  • Secret management
  • Environment isolation

15. Security Monitoring

  • Anomaly detection
  • Intrusion detection
  • Alert system

Threat Model

Assets

  1. Database Credentials: Passwords, connection strings
  2. Database Contents: User data, business data
  3. Configuration Files: Settings, secrets
  4. Audit Logs: Access history, operations
  5. Session Data: Active sessions, tokens

Threats

1. SQL Injection

Mitigation:

  • Parameterized queries only
  • Input validation
  • Query analysis
  • Whitelist patterns

2. Credential Theft

Mitigation:

  • Encrypted storage (vault)
  • No plaintext passwords
  • Secure key derivation
  • Session tokens (not passwords)

3. Unauthorized Access

Mitigation:

  • Authentication required
  • RBAC enforcement
  • Session management
  • Audit logging

4. Man-in-the-Middle (MITM)

Mitigation:

  • TLS 1.2+ required
  • Certificate validation
  • No cleartext protocols

5. Denial of Service (DoS)

Mitigation:

  • Rate limiting
  • Connection limits
  • Query timeouts
  • Resource monitoring

6. Data Leakage

Mitigation:

  • PII detection
  • Secure logging
  • Error message sanitization
  • Access controls

7. Privilege Escalation

Mitigation:

  • Least privilege
  • Permission validation
  • Audit all operations
  • Role separation

Incident Response

Preparation

  1. Designate Security Team: Identify responsible personnel
  2. Establish Procedures: Document response process
  3. Tool Preparation: Ensure tools are ready
  4. Training: Regular security training

Detection

Monitor for:

  • Failed authentication attempts
  • Unusual query patterns
  • Excessive resource usage
  • Security alerts from monitoring
# Check audit logs for anomalies
ai-shell audit-show --limit 1000 | grep FAILED

# Review security scan results
ai-shell security-scan --deep

Containment

  1. Isolate Affected Systems: Disconnect compromised components
  2. Revoke Access: Disable compromised credentials
  3. Enable Enhanced Logging: Increase monitoring
# Revoke all sessions
ai-shell session end-all

# Change credentials
ai-shell vault-add prod-db "new-secure-password" --encrypt --force

Eradication

  1. Identify Root Cause: Analyze incident
  2. Remove Threat: Eliminate malicious code/access
  3. Patch Vulnerabilities: Apply fixes
  4. Update Security: Enhance controls

Recovery

  1. Restore Services: Bring systems back online
  2. Verify Integrity: Ensure no backdoors
  3. Monitor Closely: Watch for recurrence

Lessons Learned

  1. Document Incident: Record details
  2. Analyze Response: What worked/didn't work
  3. Update Procedures: Improve for next time
  4. Share Knowledge: Educate team

Security Updates

Notification Channels

Update Process

# Check for updates
npm outdated ai-shell

# Update to latest version
npm update ai-shell

# Verify integrity
npm audit

Security Checklist

Initial Setup

  • Generate strong master encryption key
  • Configure vault for credential storage
  • Set up TLS certificates for database connections
  • Enable audit logging
  • Configure session timeouts
  • Set up rate limiting
  • Review default permissions

Regular Maintenance

  • Review audit logs (weekly)
  • Rotate credentials (quarterly)
  • Update dependencies (monthly)
  • Security scan (weekly)
  • Backup audit logs (daily)
  • Review user permissions (monthly)
  • Test incident response (quarterly)

Before Production

  • All credentials in vault (no hardcoded secrets)
  • TLS enabled for all connections
  • Audit logging enabled
  • Rate limiting configured
  • Error messages sanitized
  • Security scan passed
  • Penetration test completed
  • Incident response plan documented

Contact

Additional Resources


Last Updated: October 28, 2025 Version: 1.0.0

There aren't any published security advisories