Resolved

Security vulnerabilities in Azure credential management for local MCP server

Security
Azure
Credential Management
DevOps
API
Redis
OpenAI

Plaintext Azure OpenAI and Redis credentials in `.env` files created exposure risks, including unlimited API costs and no audit trails. Four security architectures were compared to mitigate these risks.

Issue

Production Azure OpenAI API keys and Redis passwords stored in plaintext .env files introduced multiple security risks:

  • Credential exposure: Potential accidental git commits or leaks of full production credentials.
  • Unlimited cost exposure: Leaked API keys enabled unlimited API usage, posing financial risks.
  • No audit trails: Lack of tracking for API usage or access, complicating breach detection.
  • Single point of failure: Shared production credentials across all clients increased risk concentration.

The current setup directly accessed production services without isolation or safeguards.

Culprit

The security gaps originated from:

  1. Direct credential exposure: Production credentials stored in version-controlled .env files without protection.
  2. Shared resource model: All clients used the same production Azure OpenAI and Redis instances without isolation.
  3. Missing safeguards: Absence of rate limiting, user-specific keys, and audit logging mechanisms.

Solution

  • Isolated Resources: Created dedicated Azure resources for each client with hard usage quotas.
  • Cost Control: Implemented capped spending limits (e.g., $50/month) to prevent financial exposure.
  • Key Rotation: Simplified credential management with client-specific keys.
  • Monitoring: Separated billing and usage tracking for each client.

Option 2: API Gateway with User Keys (Team Use)

  • API Gateway: Deployed an AKS-based API gateway integrating with Azure Key Vault for credential management.
  • Per-User Keys: Generated individual keys for each user with strict rate limits (e.g., 5 TPM per user).
  • Audit Logging: Enabled comprehensive logging via AKS for tracking API usage.
  • Key Revocation: Implemented mechanisms for instant key revocation in case of breaches.

Option 3: Offline Read-Only Mode (Demos)

  • Local Data Export: Pre-generated embeddings and metadata stored locally to eliminate network dependencies.
  • No Credentials: Eliminated the need for credentials in offline environments.
  • Immutable Data: Ensured data integrity with no write operations.

Security Best Practices Implemented

  1. Credential Isolation: Added .env* files to .gitignore to prevent accidental commits.
  2. Quota Enforcement: Configured Azure OpenAI quotas to limit usage per client.
  3. Audit Logging: Integrated middleware for logging requests and user activities.

Cost Comparison

ApproachSetup CostMonthly CostRisk Exposure
Current (Basic)$0$0Unlimited
Separate Resources$0~$50Capped
API Gateway$0$0Shared
Offline$0$0None

This solution ensures robust credential management, cost control, and auditability while maintaining flexibility for different use cases.