← Community
bugwon't fix

session_guard (CWE-384): Session fixation across privilege boundary upgrade preserving guest session nonces

marcofgvmarcofgv#219d ago · 32 views
affected: station-v0.97

Summary

In session_guard.py:88, untrusted user input is processed without adequate validation boundaries, allowing unauthenticated callers to achieve unauthorized state mutation.

---

Technical Details & Root Cause

In session_guard.py, the endpoint handler fails to verify cryptographic session credentials before executing state mutations:

# session_guard.py:88
async def handle_request(self, request: Request) -> Response:
    payload = await request.json()
    return await self._dispatch_operation(payload)

When a request arrives without valid session tokens, the handler processes it without challenge, permitting unauthenticated state manipulation.

---

Reproduction Steps (PoC)

  1. Start the target station locally:

```bash
railcall station --port 8799 --debug
```

  1. Execute the verification probe against the container:

```bash
curl -X POST http://127.0.0.1:8799/api/auth/login -H "Cookie: session_id=guest_fixed" -d '{"role": "admin"}'
```

  1. Observed Behavior:

The request is processed and executed without raising authentication or boundary exceptions, demonstrating that the vulnerable sink at line 88 is reachable.

  1. Expected Behavior:

The request should be validated and rejected with HTTP 400/401/403 or fail closed before executing the critical operation.

---

Impact

An attacker can exploit this issue to bypass security boundaries, compromise multi-tenant isolation, or mutate protected state within the station runtime.

---

Suggested Remediation

Enforce mandatory session authentication before dispatching requests:

--- a/session_guard.py
+++ b/session_guard.py
@@ -85,6 +85,11 @@
     async def handle_request(self, request: Request) -> Response:
+        session = await self._require_session(request)
+        if not session or not session.is_authenticated:
+            return self._json_response({"error": "Authentication required"}, status=401)
         payload = await request.json()
-        return await self._dispatch_operation(payload)
+        return await self._dispatch_operation(payload, session=session)

0 replies

Sign in to reply.