Skip to content

Security: Filter sensitive commands from suggestions #86

@noahgift

Description

@noahgift

Security Issue

The model may suggest commands containing sensitive data learned from history:

  • API keys: export AWS_SECRET_ACCESS_KEY=AKIA...
  • Passwords: mysql -p'secretpassword'
  • Tokens: curl -H "Authorization: Bearer eyJ..."
  • Private paths: ssh user@internal-server.company.com

Proposed Solution

1. Training-time filtering

Filter sensitive patterns before training:

fn is_sensitive(cmd: &str) -> bool {
    let patterns = [
        r"(?i)(api[_-]?key|secret|token|password|passwd|pwd)\s*=",
        r"(?i)bearer\s+[a-zA-Z0-9_-]+",
        r"(?i)-p'[^']+'",  // mysql -p'password'
        r"(?i)authorization:\s*",
        r"AKIA[0-9A-Z]{16}",  // AWS access key
    ];
    patterns.iter().any(|p| Regex::new(p).unwrap().is_match(cmd))
}

2. Suggestion-time filtering

Double-check before returning suggestions:

fn suggest(prefix: &str) -> Option<String> {
    let suggestion = model.predict(prefix)?;
    if is_sensitive(&suggestion) {
        return None;
    }
    Some(suggestion)
}

3. User-configurable blocklist

# ~/.config/aprender-shell/config.toml
[security]
block_patterns = [
    "internal\\.company\\.com",
    "prod-database",
]

4. Train command flag

aprender-shell train --filter-sensitive  # Default: on
aprender-shell train --no-filter-sensitive  # Opt-out

Priority

High - This is a data leak vector, especially for shared/exported models.

Related

  • Affects export/import commands - shared models could leak secrets

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions