Skip to content

harden: secure main.py (multi_agent.cwe-862) - #77

Open
anupamme wants to merge 1 commit into
parallel-web:mainfrom
anupamme:fix-repo-parallel-cookbook-cwe-862-enrich-auth
Open

anupamme wants to merge 1 commit into
parallel-web:mainfrom
anupamme:fix-repo-parallel-cookbook-cwe-862-enrich-auth

Conversation

@anupamme

@anupamme anupamme commented Oct 6, 2026

Copy link
Copy Markdown

The /api/enrich/bulk and related enrichment endpoints lack visible authentication middleware. Without explicit authentication checks, these expensive operations can be triggered by unauthenticated attackers. This is defence-in-depth at python-recipes/parallel-investor-signals/project/backend/main.py:273 rather than a vulnerability I can show is exploitable here — it makes the failure mode explicit and bounded. Close it freely if the pattern is intentional.

What changed

  • python-recipes/parallel-investor-signals/project/backend/main.py

Verification

No automated check could be run against this repository, so this change is unverified beyond review. Please treat it as a suggestion.

Regression test

The security boundary is maintained under adversarial input

Test
import pytest
from fastapi.testclient import TestClient
import sys
import os

sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'python-recipes', 'parallel-investor-signals', 'project', 'backend'))
from main import app


@pytest.mark.parametrize("endpoint,payload", [
    ("/api/enrich", {"ticker": "AAPL"}),
    ("/api/enrich/bulk", {"tickers": ["AAPL", "MSFT"]}),
    ("/api/enrich/custom", {"ticker": "GOOGL", "fields": ["price"]}),
])
def test_enrichment_endpoints_require_authentication(endpoint, payload):
    """Invariant: Enrichment endpoints must reject unauthenticated requests with 401 Unauthorized."""
    client = TestClient(app)
    response = client.post(endpoint, json=payload)
    assert response.status_code in (401, 403), \
        f"Endpoint {endpoint} must require authentication, got {response.status_code}"

Automated security fix by OrbisAI Security

Automated security fix generated by OrbisAI Security

Signed-off-by: anupamme <mediratta@gmail.com>
@anupamme
anupamme requested a review from a team October 6, 2026 05:18

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant