Skip to content

Commit 615eb30

Browse files
authored
Merge pull request #51 from stenwire/main
deploy
2 parents 31a1191 + 251aec2 commit 615eb30

4 files changed

Lines changed: 56 additions & 3 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ env:
2929
-e GOOGLE_CLIENT_SECRET="${{ secrets.GOOGLE_CLIENT_SECRET }}"
3030
-e GOOGLE_REDIRECT_URI="${{ secrets.GOOGLE_REDIRECT_URI }}"
3131
-e FRONTEND_REDIRECT_URI="${{ secrets.FRONTEND_REDIRECT_URI }}"
32+
-e JWT_SECRET="${{ secrets.JWT_SECRET }}"
3233
3334
FRONTEND_ENV: >-
3435
-e NODE_ENV="production"

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ start:
2222
start-d:
2323
docker-compose up -d
2424

25+
# Run tests for backend
26+
backend-test:
27+
docker-compose exec backend uv run pytest . -v
28+
2529
# Stop all services
2630
stop:
2731
docker-compose down
@@ -102,4 +106,4 @@ db-truncate:
102106

103107
# Show running containers
104108
ps:
105-
docker-compose ps
109+
docker-compose ps

backend/alembic/env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626

2727
if all([POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB]):
2828
database_url = f"postgresql://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{POSTGRES_HOST}:{POSTGRES_PORT}/{POSTGRES_DB}"
29-
config.set_main_option("sqlalchemy.url", database_url)
29+
config.set_main_option("sqlalchemy.url", database_url.replace("%", "%%"))
3030
else:
3131
# Fallback: if individual vars are missing, try the full DATABASE_URL (e.g., from Heroku, Render, Railway)
3232
fallback_url = os.getenv("DATABASE_URL")
3333
if fallback_url:
34-
config.set_main_option("sqlalchemy.url", fallback_url)
34+
config.set_main_option("sqlalchemy.url", fallback_url.replace("%", "%%"))
3535

3636
# Logging setup
3737
if config.config_file_name is not None:

security_incident_report.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Security Incident Report
2+
**Date:** January 31, 2026
3+
**Project:** TaimakoAI
4+
**Severity:** Critical
5+
**Status:** Resolved (Monitoring Required)
6+
7+
## Executive Summary
8+
On January 31, 2026, during routine maintenance, a **Critical Remote Code Execution (RCE)** vulnerability was detected in the frontend application. The vulnerability allowed unauthorized actors to execute system commands on the server. The attack vector was identified as a known security flaw in **Next.js 16.0.3**. Immediate remediation was performed by patching the software and restricting network configurations.
9+
10+
## 1. Incident Details
11+
- **Component:** `taimako_frontend` (Next.js Application)
12+
- **Vulnerability Type:** Remote Code Execution (RCE) via Deserialization (CVE-2025-55182 / CVE-2025-66478)
13+
- **Affected Version:** Next.js `16.0.3`
14+
- **Detected:** January 31, 2026, 17:21 PM (local time) based on 502 Bad Gateway investigation.
15+
16+
## 2. Root Cause Analysis
17+
The application was running an outdated version of Next.js (`16.0.3`) which contained a critical vulnerability in the React Server Components (RSC) payload handling.
18+
- **Mechanism:** Attackers sent maliciously crafted HTTP requests that the server deserialized, resulting in arbitrary shell command execution.
19+
- **Exploitation:** Logs confirmed active exploitation where attackers ran commands to list directories and print environment variables.
20+
21+
## 3. Detection & Evidence
22+
The incident was discovered while investigating `502 Bad Gateway` errors. Review of the Docker logs (`docker logs taimako_frontend`) revealed:
23+
- **Abnormal Error Dumps**: `NEXT_REDIRECT` errors containing output of system commands.
24+
- **Command Execution**:
25+
- `ls -la /var/www/.env*` (Attempting to locate secret files)
26+
- `id`, `uname` (System reconnaissance)
27+
- `base64` verification logic.
28+
- **Environment Leak**: Error stack traces displayed the contents of environment variables, including configuration keys.
29+
30+
## 4. Resolution & Mitigation
31+
The following corrective actions were taken immediately:
32+
1. **Software Patch**: Upgraded `next` dependency from `16.0.3` to `^16.0.7` (Current installed: `16.1.6`).
33+
2. **Configuration Hardening**:
34+
- Refactored Backend configuration to enforce **Strict CORS** policies in production.
35+
- Centralized middleware management.
36+
3. **Secret Rotation (Required User Action)**:
37+
- Initiated rotation protocol for `POSTGRES_PASSWORD`, `JWT_SECRET`, and `GOOGLE_CLIENT_SECRET`.
38+
39+
## 5. Impact Assessment
40+
- **Data Confidentiality**: **High Risk**. Environment variables were exposed in logs. Secrets must be assumed compromised.
41+
- **Data Integrity**: **Medium Risk**. Attackers had shell access, but no evidence of database deletion was found in the limited log window.
42+
- **Availability**: **High Impact**. The attack caused the frontend service to crash repeatedly (502 errors).
43+
44+
## 6. Recommendations & Next Steps
45+
1. **Immediate**: Complete the rotation of all production secrets (Database, JWT, API Keys).
46+
2. **Deployment**: Re-deploy all services with the patched Docker images.
47+
3. **Monitoring**: Monitor logs for the next 48 hours for any "NEXT_REDIRECT" anomalies or suspicious IP activity.
48+
4. **Process**: Implement a dependency scanning tool (e.g., Dependabot or Snyk) to catch upstream vulnerabilities earlier.

0 commit comments

Comments
 (0)