| Version | Supported |
|---|---|
| 1.x.x | ✅ |
| < 1.0 | ❌ |
If you discover a security vulnerability, please report it by emailing [email protected].
Please do NOT report security vulnerabilities through public GitHub issues.
- Description of the vulnerability
- Steps to reproduce
- Potential impact
- Any suggested fixes (optional)
- Initial Response: Within 48 hours
- Status Update: Within 7 days
- Resolution: Depends on severity and complexity
- Acknowledgment of your report
- Assessment of the vulnerability
- Development of a fix
- Coordinated disclosure (if applicable)
- Credit in the release notes (unless you prefer anonymity)
Identifier Sanitization (src/utils/identifiers.ts)
- All table, column, schema, and index names are validated and quoted
- PostgreSQL identifier rules enforced: start with letter/underscore, contain only alphanumerics, underscores, or $ signs
- Maximum 63-character limit enforced
- Invalid identifiers throw
InvalidIdentifierError
Key functions:
sanitizeIdentifier(name)— Validates and double-quotes an identifiersanitizeTableName(table, schema?)— Handles schema-qualified table referencessanitizeColumnRef(column, table?)— Handles column references with optional table qualifiersanitizeIdentifiers(names[])— Batch sanitization for column lists
Parameterized Queries
- All user-provided values use parameterized queries via
pglibrary - Identifier sanitization complements parameterized values
Rate Limiting (enabled by default)
- 100 requests per minute per IP address
- Configurable via
rateLimitMaxRequestsandrateLimitWindowMs - Returns
429 Too Many Requestswhen exceeded
Request Body Limits
- Maximum 1MB request body (configurable via
maxBodySize) - Prevents memory exhaustion attacks
Security Headers
X-Content-Type-Options: nosniffX-Frame-Options: DENYX-XSS-Protection: 1; mode=blockCache-Control: no-store, must-revalidateContent-Security-Policy: default-src 'none'
HSTS Support
- Optional
Strict-Transport-Securityheader for HTTPS deployments - Enable via
enableHSTS: trueconfiguration
CORS Configuration
- Origin whitelist with
Vary: Originheader for caching - Optional credentials support (
corsAllowCredentials) - MCP-specific headers allowed (
X-Session-ID,mcp-session-id)
- RFC 9728 Protected Resource Metadata at
/.well-known/oauth-protected-resource - RFC 8414 Authorization Server Metadata discovery
- JWT token validation with JWKS caching
- PostgreSQL-specific scopes:
read,write,admin,full,db:{name},schema:{name},table:{schema}:{table}
Credential Redaction
- Sensitive fields automatically redacted in logs:
password,secret,token,apikey,issuer,audience,jwksUri,credentials, etc. - Recursive sanitization for nested objects
Log Injection Prevention
- Control character sanitization (ASCII 0x00-0x1F except tab/newline, 0x7F, C1 characters)
- Prevents log forging and escape sequence attacks
When using postgres-mcp:
- Never commit database credentials to version control
- Use environment variables for sensitive configuration
- Restrict database user permissions to minimum required
- Keep dependencies updated
- Enable SSL for database connections in production
- Use OAuth 2.1 authentication for HTTP transport in production
- Enable HSTS when running over HTTPS
- Configure CORS origins explicitly (avoid wildcards)