| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Current Version: 1.0.10
The Admin UI should never be exposed in production environments. It is designed exclusively for:
For production deployments:
Disable unused features using environment variables and feature flags (MCPGATEWAY_ENABLE_PROMPTS=false, etc.) as per 537
Use the REST API only, with strict input validation and authentication
Disable Admin UI and Admin API in production (MCPGATEWAY_UI_ENABLED=false, MCPGATEWAY_ADMIN_API_ENABLED=false)
Run containers as non-root users, with read-only filesystems and minimal base images
Harden network access with firewalls, ingress policies, and internal-only endpoints
Set resource limits (CPU, memory) to protect against denial-of-service risks
Always deploy the latest version โ there are no backported security patches or long-term support branches
Perform a security audit of the codebase yourself, especially if deploying in regulated, multi-tenant, or production environments
Integrate as part of a comprehensive solution: ContextForge is not a standalone product. It is designed to be one layer in a larger, secure system architecture. You should integrate it with complementary components such as:
Always consider your full deployment context and threat model when using ContextForge as part of a broader system.
Please review https://ibm.github.io/mcp-context-forge/architecture/multitenancy/
ContextForge project implements a comprehensive, multi-layered security approach designed to protect against vulnerabilities at every stage of the development lifecycle. Our security strategy is built on the principle of "defense in depth," and "secure by design", incorporating Static Application Security Testing (SAST), Dynamic Application Security Testing (DAST), Software Composition Analysis (SCA), Interactive Application Security Testing (IAST), fuzz testing, mutation testing, chaos engineering, mandatory code reviews and continuous monitoring to ensure the highest security standards.
As a gateway service that handles Model Context Protocol (MCP) communications and potentially sensitive data flows, security is paramount to our design philosophy. We recognize that modern software security requires proactive measures rather than reactive responses - an a "secure by design" mindset. Our approach combines industry-standard security practices, and secure "defaults" with automated tooling to create a robust security posture.
Here's an expanded section for that part:
Tools are not enough: While our automated security tooling provides comprehensive coverage, we recognize that true security requires human expertise and collaborative oversight. Our security posture extends beyond automated scanning to include:
This human-centered approach ensures that security is not just a technical implementation detail, but a fundamental aspect of how we design, build, and maintain ContextForge service.
Our security pipeline operates at multiple levels:
Pre-commit Security Gates: Before any code reaches our repository, it must pass through rigorous pre-commit hooks that include multiple security scanners like Bandit for common security issues, Semgrep for semantic pattern matching, Dodgy for hardcoded secrets detection, and detect-private-key for catching committed private keys, along with type checking and code quality enforcement. Pre-commit hooks also enforce AI content integrity (preventing AI-generated artifacts such as hallucinated citations, stock phrases, and malformed code fences) and Unicode safety (fixing smart quotes, ligatures, and forbidding BiDi control characters to prevent trojan-source attacks). Developers can run make security-all or make pre-commit bandit semgrep dodgy lint locally to execute these same security checks before pushing code.
Continuous Integration Security: Our GitHub Actions workflows implement automated security scanning on every pull request and commit, with 40+ security scans triggering automatically on every PR, including Semgrep for semantic analysis, detect-secrets for secret detection with baseline allowlist, comprehensive dependency vulnerability scanning with pip-audit, npm audit, and cargo audit, SBOM generation, and Hadolint-style linting where configured, IaC scanning with Checkov and kube-linter, GitHub Actions security linting with Zizmor, and multi-language static analysis across Python, Go, Rust, Shell, and JavaScript.
Code Review Security: All code changes undergo mandatory peer review with security-focused review criteria, ensuring that security considerations are evaluated by human experts in addition to automated tooling.
Supply Chain Security: We maintain strict oversight of our software supply chain through automated dependency vulnerability scanning, Software Bill of Materials (SBOM) generation, and license compliance checking to ensure all components meet security standards. Dependency vulnerability findings are surfaced via Dependabot and regularly reviewed and addressed by contributors. Snyk custom rules enforce detection of hardcoded JWT secrets and basic auth credentials (CWE-798). License policies explicitly deny strong-copyleft licenses (GPL-3.0, AGPL-3.0, SSPL) and flag licenses requiring review (MPL-2.0, LGPL-2.0, CC-BY-SA-4.0).
Container Security Hardening: Our containerized deployments follow security best practices including multi-stage builds, minimal base images (UBI Micro) with the latest updates, non-root user execution, read-only filesystems, and SBOM-based review with complementary dependency and OS/package analysis where configured.
Runtime Security Monitoring: Beyond build-time security, we implement runtime monitoring and security policies to detect and respond to potential threats in production environments.
Our security toolchain includes 40+ different security and quality tools, each serving a specific purpose in our defense strategy and executed on every pull request:
We believe that security should enhance rather than hinder the development process. Our comprehensive make targets provide developers with easy access to the full security suite, allowing them to run the same checks locally that will be executed in CI/CD:
Core Security Commands:
Individual Security Tools:
IaC, CI/CD & Multi-Language Security:
Local-First Security: Developers are encouraged to run make pre-commit and make test before every commit, ensuring that security issues are caught and resolved locally before code reaches the repository. This "shift-left" approach means security problems are identified early in the development process, reducing the time and cost of remediation.
CI/CD Security Enforcement: Even with local testing, our CI/CD pipeline runs the complete security suite on every pull request, with 40+ security scans executed automatically across Python, Go, Rust, Shell, JavaScript, IaC, and container targets. This dual-layer approach ensures no security issues slip through, while the local tooling provides rapid feedback to developers.
This approach ensures that security is integrated into daily development workflows rather than being an afterthought, while maintaining the aggressive response timelines our users expect.
Our security posture is continuously evolving. We regularly update our toolchain, review new security practices, and incorporate feedback from the security community. The comprehensive nature of our pipeline means that security vulnerabilities are caught early and addressed promptly, maintaining the integrity of ContextForge service.
As of version 0.3.1, ContextForge implements comprehensive input validation across all API endpoints using the SecurityValidator class with strict validation rules:
These validation rules help prevent XSS injection when data from untrusted MCP servers is displayed in downstream UIs. However, the gateway is only one layer of defense - downstream applications should implement their own validation and sanitization appropriate to their specific use cases.
ContextForge implements enterprise-grade XSS protection through the SecurityValidator class:
HTML Sanitization:
Polyglot Attack Prevention:
Character Validation:
Pydantic Integration:
Example Usage:
from mcpgateway.common.validators import SecurityValidator
# Sanitize user-provided text
safe_text = SecurityValidator.sanitize_display_text(user_input)
# Validate tool names
SecurityValidator.validate_tool_name(tool_name)
# Validate identifiers
SecurityValidator.validate_identifier(identifier)ContextForge implements comprehensive SSRF protection through validate_url():
HTTP Redirect Hardening:
Scheme Allowlist:
Network Security:
Length & Format Validation:
Example Usage:
from mcpgateway.common.validators import SecurityValidator
# Validate external URLs before making requests
try:
SecurityValidator.validate_url(url, "External API endpoint")
except ValueError as e:
logger.error(f"Invalid URL rejected: {e}")
raiseAs of version 1.0.0-RC-2, ContextForge implements log injection protection to prevent attackers from forging log entries:
Protection Mechanism:
Attack Prevention:
As of version 1.0.0-RC-2, ContextForge implements comprehensive Jinja2 template injection protection to prevent code execution attacks through malicious prompt templates:
Protection Mechanism:
Validation Layers:
Balanced Braces Check:
Dangerous Pattern Detection:
Jinja2 Syntax Validation:
Attack Prevention:
Configuration:
# Enable validation (default: true)
CONTENT_VALIDATE_PROMPT_TEMPLATES=true
# Customize blocked patterns (JSON array of regex patterns)
CONTENT_BLOCKED_TEMPLATE_PATTERNS='["__import__","eval\\s*\\(","exec\\s*\\(","__.*__"]'Example Usage:
from mcpgateway.services.content_security import get_content_security_service, TemplateValidationError
security = get_content_security_service()
try:
# Validate template before storage
security.validate_prompt_template(
template="Hello {{ name }}!",
name="greeting_prompt",
user_email="user@example.com",
ip_address="192.168.1.1"
)
except TemplateValidationError as e:
logger.error(f"Template validation failed: {e.reason}")
# Returns HTTP 400 with detailed error informationSecurity Audit Trail:
Integration Points:
Performance:
Validation overhead: < 1ms for simple templates, < 5ms for complex templates
Can be disabled via configuration if needed (not recommended)
Patterns compiled once at startup for efficiency
Prevents hiding malicious activity in logs
Ensures log integrity for security auditing
Example Usage:
from mcpgateway.common.validators import SecurityValidator
# Sanitize user-controlled data before logging
logger.info(f"User {SecurityValidator.sanitize_log_message(user_email)} requested resource")
logger.error(f"Failed to process: {SecurityValidator.sanitize_log_message(error_message)}")
logger.debug(f"Session {SecurityValidator.sanitize_log_message(session_id)} established")Implementation Status:
Developer Guidelines:
Starting with v0.3.1, ContextForge follows the principle of "secure by default":
To enable admin features for development:
MCPGATEWAY_UI_ENABLED=true # Default: false
MCPGATEWAY_ADMIN_API_ENABLED=true # Default: falseStarting with 0.1.0:
Important: The Admin UI is provided for developer convenience only and should never be enabled in production deployments.
Tokens must not be valid across DEV/STAGING/PROD.
Required:
The env claim alone is not a security boundary. With DERIVE_KEY_PER_ENVIRONMENT=false and a shared JWT_SECRET_KEY, anyone holding that secret can mint a token with env=production and pass validation. The claim is defense-in-depth/diagnostics only; real isolation comes from a distinct or derived signing key per environment.
Derived-key strength inherits the base secret. DERIVE_KEY_PER_ENVIRONMENT re-keys per environment but does not strengthen a weak JWT_SECRET_KEY โ a weak base secret still yields a weak derived key. Use a strong, random JWT_SECRET_KEY regardless (existing weak-secret checks apply).
Rollout order:
Federation: Cross-environment UAID federation is unsupported by design. Same-environment federation peers must share JWT_SECRET_KEY and ENVIRONMENT so derived keys match.
Scope: Applies to gateway-issued tokens. External OAuth/SSO/JWKS tokens are governed by issuer pinning and are out of scope.
ContextForge provides important security controls but is designed to be one component in a comprehensive defense-in-depth strategy:
Before connecting any MCP server to the gateway:
Applications consuming data from ContextForge should:
When deploying ContextForge in production:
The following diagram illustrates our comprehensive security scanning pipeline:
๐ Click to view the complete security scanning flowchartflowchart TD
A[Code Changes] --> B{Pre-commit Hooks}
B --> C[Ruff - Python Linter/Formatter]
B --> D[Black - Code Formatter]
B --> E[isort - Import Sorter]
B --> F[mypy - Type Checking]
B --> G[Bandit - Security Scanner]
B --> G1[Semgrep - Semantic Security]
B --> G2[Dodgy - Secret Detection]
B --> G3[detect-private-key]
B --> G4[AI Content Integrity Hooks]
B --> G5[Unicode/BiDi Safety - texthooks]
C --> H[Pre-commit Success?]
D --> H
E --> H
F --> H
G --> H
G1 --> H
G2 --> H
G3 --> H
G4 --> H
G5 --> H
H -->|No| I[Fix Issues & Retry]
I --> B
H -->|Yes| J[Push to GitHub]
J --> K[GitHub Actions Triggers]
K --> L[Python Package Build]
K --> M[CodeQL Analysis]
K --> N[Python Security Suite]
K --> O[Dependency Review]
K --> P[Tests & Coverage]
K --> Q[Lint & Static Analysis]
K --> R[Docker Image Build]
K --> S[Container Security Scan]
K --> IA[IaC & CI/CD Security]
K --> ML[Multi-Language Security]
L --> L1[Python Build Test]
L --> L2[Package Installation Test]
M --> M1[Semantic Code Analysis]
M --> M2[Security Vulnerability Detection]
M --> M3[Data Flow Analysis]
N --> N1[Bandit - Security Issues]
N --> N2[Semgrep - Semantic Patterns]
N --> N3[Dodgy - Hardcoded Secrets]
N --> N4[detect-secrets - Baseline-Audited Secret Scanning]
N --> N6[Prospector - Comprehensive Analysis]
N --> N7[Interrogate - Docstring Coverage]
N --> N8[DevSkim - Security Anti-patterns]
O --> O1[Dependency Vulnerability Check]
O --> O2[License Compliance]
O --> O3[Supply Chain Security]
O --> O4[pip-audit - Python CVEs]
O --> O5[Snyk - Custom Security Rules]
O --> O6[Dependabot - Vulnerability Findings]
P --> P1[pytest Unit Tests]
P --> P2[Coverage Analysis]
P --> P3[Integration Tests]
P --> P4[Playwright Security E2E]
P --> P5[diff-cover - PR Coverage Gate]
IA --> IA1[Checkov - IaC Security]
IA --> IA2[kube-linter - K8s Best Practices]
IA --> IA3[Zizmor - Actions Security]
IA --> IA4[actionlint - Actions Validation]
ML --> ML1[Go Security]
ML --> ML2[Rust Security]
ML --> ML3[Shell Security]
ML1 --> ML1A[gosec - Static Analysis]
ML1 --> ML1B[golangci-lint - Linting]
ML1 --> ML1C[govulncheck - Vuln DB]
ML2 --> ML2A[cargo audit - Dependency Vulns]
ML2 --> ML2B[cargo clippy - Linting]
ML3 --> ML3A[shellcheck - Script Analysis]
Q --> Q1[Multiple Linters]
Q --> Q2[Static Analysis Tools]
Q1 --> Q1A[ruff - PEP8 Compliance]
Q1 --> Q1B[pylint - Code Quality]
Q1 --> Q1C[pycodestyle - Style Guide]
Q1 --> Q1D[pydocstyle - Documentation]
Q1 --> Q1E[markdownlint - Markdown Files]
Q1 --> Q1F[yamllint - YAML Files]
Q1 --> Q1G[jsonlint - JSON Files]
Q1 --> Q1H[tomllint - TOML Files]
Q2 --> Q2A[mypy - Type Checking]
Q2 --> Q2B[pyright - Type Analysis]
Q2 --> Q2C[pytype - Google Type Checker]
Q2 --> Q2D[radon - Complexity Analysis]
Q2 --> Q2E[pyroma - Package Metadata]
Q2 --> Q2F[importchecker - Import Analysis]
Q2 --> Q2G[fawltydeps - Dependency Analysis]
Q2 --> Q2H[check-manifest - Package Completeness]
Q2 --> Q2I[pyupgrade - Syntax Modernization]
R --> R1[Docker Build]
R --> R2[Multi-stage Build Process]
R --> R3[Security Hardening]
S --> S1[Hadolint - Dockerfile Linting]
S --> S2[Dockle - Container Security]
S --> S3[Container review guidance]
S --> S4[OSV-Scanner - Open Source Vulns]
T[Local Development] --> U[Make Targets]
U --> V[make lint - Full Lint Suite]
U --> W[Security Make Targets]
U --> X[make sbom - Software Bill of Materials]
U --> Y[make lint-web - Frontend Security]
V --> V1[All Python Linters]
V --> V2[Code Quality Checks]
V --> V3[Style Enforcement]
W --> W1[make security-all - Run All Security Tools]
W --> W2[make security-report - Generate Report]
W --> W3[make security-fix - Auto-fix Issues]
W --> W4[make bandit - Security Scanner]
W --> W5[make semgrep - Semantic Analysis]
W --> W6[make dodgy - Secret Detection]
W --> W7[make detect-secrets-scan - Baseline-Audited Secret Scan]
W --> W9[make interrogate - Docstring Coverage]
W --> W10[make pyupgrade - Modernize Syntax]
W --> W12[make pip-audit - Dependency Scanning]
W --> W13[make osv-scan - Vulnerability Check]
W --> W14[make security-scan - Container Review]
W --> W15[make dockle - Image Analysis]
W --> W16[make hadolint - Dockerfile Linting]
W --> W17[make devskim - Security Anti-patterns]
W --> W20[make linting-security-checkov]
W --> W21[make linting-security-kube-linter]
W --> W22[make linting-workflow-zizmor]
W --> W23[make linting-go-gosec]
W --> W24[make shell-lint - shellcheck]
X --> X1[CycloneDX SBOM Generation]
X --> X2[Dependency Inventory]
X --> X3[License Compliance Check]
X --> X4[Vulnerability Assessment]
Y --> Y1[htmlhint - HTML Validation]
Y --> Y2[stylelint - CSS Security]
Y --> Y3[eslint - JavaScript Security]
Y --> Y4[retire.js - JS Library Vulnerabilities]
Y --> Y5[npm audit - Package Vulnerabilities]
Y --> Y6[nodejsscan - JS Security Vulns]
Z[Additional Security Tools] --> Z1[SonarQube Analysis]
Z --> Z2[WhiteSource Security Scanning]
Z --> Z3[Spellcheck - Documentation]
Z --> Z4[Pre-commit Hook Validation]
AA[Container Security Pipeline] --> AA1[Multi-stage Build]
AA --> AA2[Minimal Base Images]
AA --> AA3[Security Hardening]
AA --> AA4[Runtime Security]
AA1 --> AA1A[Build Dependencies]
AA1 --> AA1B[Runtime Dependencies]
AA1 --> AA1C[Security Scanning]
AA2 --> AA2A[UBI Micro Base]
AA2 --> AA2B[Minimal Attack Surface]
AA2 --> AA2C[No Shell Access]
AA3 --> AA3A[Non-root User]
AA3 --> AA3B[Read-only Filesystem]
AA3 --> AA3C[Capability Dropping]
AA4 --> AA4A[Runtime Monitoring]
AA4 --> AA4B[Security Policies]
AA4 --> AA4C[Vulnerability Patching]
classDef security fill:#ff6b6b,stroke:#d63031,stroke-width:2px
classDef linting fill:#74b9ff,stroke:#0984e3,stroke-width:2px
classDef container fill:#00b894,stroke:#00a085,stroke-width:2px
classDef process fill:#fdcb6e,stroke:#e17055,stroke-width:2px
classDef success fill:#55a3ff,stroke:#2d3436,stroke-width:2px
class G,G1,G2,G3,G4,G5,M,N,O,W,W1,W2,W3,W4,W5,W6,W7,W8,W12,W13,W18,W19,W20,W21,W22,W23,W24,Z1,Z2,AA,N1,N2,N3,N4,N5,N6,N7,N8,N9,O4,O5,O6,IA,IA1,IA2,IA3,IA4,ML,ML1,ML2,ML3,ML1A,ML1B,ML1C,ML2A,ML2B,ML3A,Y6 security
class C,D,E,F,Q,Q1,Q1A,Q1B,Q1C,Q1D,Q1E,Q1F,Q1G,Q1H,V,W9,W10,Q2I linting
class R,S,S1,S2,S3,S4,S5,AA,AA1,AA2,AA3,AA4,W14,W15,W16,W17 container
class B,H,K,L,P,T,U,V,W,X,Y,Z process
class L1,L2,M1,M2,M3,P1,P2,P3,P4,P5 success
โ ๏ธ Important: ContextForge is an OPEN SOURCE PROJECT provided "as-is" with NO OFFICIAL SUPPORT from IBM or its affiliates. Community contributions and best-effort maintenance are provided by project contributors.
All Container Images and Python dependencies are updated with every release (major or minor) or on CRITICAL/HIGH security vulnerabilities (triggering a minor release), subject to maintainer availability. However, since ContextForge is provided as-is, you are strongly encouraged to perform your own vulnerability scanning and apply security patches to your deployments, especially if you are customizing or extending base images or dependencies. Relying solely on upstream updates may not be sufficient for your production security posture.
โ ๏ธ Disclaimer: All patching and response timelines below are provided on a best-effort basis with no service-level agreements (SLAs), guarantees, or commercial support. ContextForge is an open-source project maintained by the community without official backing from IBM or its affiliates.
Our security patching strategy prioritizes meaningful updates while maintaining overall system stability:
Critical and High-Severity Vulnerabilities: Best-effort patches are typically released within 1 week of discovery or disclosure. These updates usually result in a minor version bump (e.g., 0.3.1).
Medium-Severity Vulnerabilities: Addressed in the next scheduled release, usually within 2 weeks of identification.
Low-Severity Vulnerabilities: Included in regular maintenance updates, typically resolved across 1โ2 upcoming releases (~2โ4 weeks), depending on impact and availability.
There are no formal zero-day patch guarantees; users are expected to evaluate risks and apply any necessary mitigations on their own infrastructure.
All security patches undergo best-effort verification:
This process ensures that security patches not only address vulnerabilities but maintain the reliability and performance characteristics of ContextForge service.
Report a security issue via e-mail or anonymous form to the IBM Product Security Incident Response Team (PSIRT) following the guidelines under the IBM Security Vulnerability Management pages.
Thank you for helping to keep the project secure!
| Back | FazBrowse Home | New Git URL |