Skip to content

Security: Encrypt Google Drive token storage and lock down token file permissions #135

@techmore

Description

@techmore

Title: Encrypt Google Drive token storage and lock down token file permissions
Type: security
Severity: high
Area: Google Drive integration / token persistence

Description:
Google Drive OAuth tokens are currently stored as plaintext JSON under data/google_drive_tokens.json. The current save path does not apply encryption or restrictive file permissions. On a shared machine or copied bundle/data directory, refresh tokens can be extracted and reused.

Evidence:

  • nmapui/google_drive.py writes tokens with _save_json_file() and plain json.dumps(...)
  • nmapui/paths.py defines GOOGLE_DRIVE_TOKEN_FILE = BASE_DIR / "data" / "google_drive_tokens.json"
  • No chmod(0600) or platform keychain integration is applied during token writes

Proposed Fix:
Move token persistence to an encrypted secret store. On macOS, prefer Keychain-backed storage. If file storage remains as fallback, encrypt the payload and explicitly apply owner-only permissions.

Implementation Notes:

  • Introduce a storage abstraction so auth/status/upload code stops assuming plaintext JSON
  • Support migration from the existing plaintext token file
  • Add tests for permission setting and migration behavior

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions