Skip to content

Code Protection ​

GhostAI protects proprietary source code and secrets from being sent to external AI models.

Overview ​

Code protection prevents accidental or intentional exposure of:

  • Source Code: Proprietary algorithms and implementations
  • Secrets: API keys, passwords, tokens, certificates
  • Configuration: Database URLs, internal endpoints
  • Intellectual Property: Trade secrets, proprietary logic

Protection Policies ​

GhostAI offers three policy modes that control how detected code and secrets are handled:

PolicyBehaviorUse Case
WarnShow dialog, allow after confirmationDefault, balanced
BlockPrevent sending entirelyHigh security
RedactAuto-tokenize code and secretsSeamless protection

Administrators can set the active policy through the Settings UI or via server-side configuration.

Language Detection ​

GhostAI detects source code across 30+ programming languages, spanning web, backend, systems, mobile, data science, and DevOps categories.

Detection uses confidence scoring to classify content and minimize false positives. Administrators can adjust the sensitivity threshold to balance between strict detection and permissiveness based on their organization's risk tolerance.

Secrets Detection ​

GhostAI identifies API keys, tokens, passwords, private keys, and connection strings from 50+ cloud and SaaS providers. Detected secrets are surfaced to users before any message is sent to an external model.

Detection Categories ​

CategoryExamples
API KeysProvider-specific key formats
PasswordsCredentials in connection strings
TokensJWT, OAuth, and personal access tokens
Private KeysPEM-encoded keys and certificates
Database URLsConnection strings with embedded credentials
Cloud CredentialsCloud provider access keys and secrets

User Experience ​

Warn Mode ​

When code or secrets are detected under the warn policy, users see a dialog summarizing what was found — including detected languages, line counts, and any secrets. Users can choose to cancel, send anyway (logged), or redact and send.

Redaction ​

GhostAI supports two redaction approaches:

  • Full redaction: Replaces entire code blocks with opaque tokens
  • Partial redaction: Preserves code structure but replaces secrets with safe placeholders

Redacted content is tokenized so the original values are never transmitted to external models.

File Uploads ​

When files containing code are uploaded, GhostAI scans and summarizes detected content — including language, line count, and any embedded secrets — before the file is sent.

API ​

Detect Code ​

POST /api/detect/code

Analyzes text for source code and secrets. Returns detection results including language, confidence, and any secrets found.

Set Code Policy ​

PUT /api/settings/code-policy

Sets the active code protection policy. Requires authentication.

Configuration ​

Administrators can configure code protection through server-side settings:

  • Policy mode: Choose between warn, block, or redact
  • Detection sensitivity: Adjust the confidence threshold for code detection
  • Language scope: Enable or disable detection for specific language categories
  • Provider scope: Control which secret providers are included in scanning

Per-language overrides are available for organizations that need to exclude certain content types (e.g., Markdown) or flag specific languages as high-sensitivity.

Audit Trail ​

All code detection events are logged, capturing the timestamp, detected language, confidence level, number of secrets found, the policy action taken, and the user's response. These logs support compliance reporting and incident review.

Best Practices ​

  1. Use "warn" for developers — Allows flexibility while raising awareness
  2. Use "block" for compliance — Prevents any code exposure
  3. Use "redact" for workflows — Seamless protection without interruption
  4. Review audit logs — Identify patterns in code exposure attempts
  5. Educate users — Help team understand why protection matters

Compliance Benefits ​

  • Prevents inadvertent disclosure of trade secrets and proprietary source code
  • Detects and blocks credential leakage before it reaches third-party models
  • Provides a full audit trail for regulatory and internal compliance reviews
  • Supports configurable policies to align with organizational security requirements

Next Steps ​

SOC 2 Type II Certified | BAA Available | HIPAA-Ready