Skip to content

Bug: POST /api/v1/workflows/scheduler/tick has no rate limiter, allowing any authenticated caller to trigger unlimited scheduler ticks #474

@anshul23102

Description

@anshul23102

What happened?

Every resource-intensive endpoint in backend/secuscan/routes.py uses a dedicated rate limiter:

@router.post("/task/start", dependencies=[Depends(task_start_limiter)])
@router.get("/task/{task_id}/report/csv", dependencies=[Depends(report_download_limiter)])
@router.get("/dashboard/summary", dependencies=[Depends(read_heavy_limiter)])
@router.get("/vault", dependencies=[Depends(vault_limiter)])

The scheduler tick endpoint is the only execution endpoint with no such limiter:

@router.post("/workflows/scheduler/tick")
async def trigger_workflow_tick():
    await scheduler.tick()   # No rate limiter
    return {"tick": "ok"}

Steps to Reproduce

  1. Obtain a valid API key.
  2. Send POST /api/v1/workflows/scheduler/tick repeatedly in a tight loop.
  3. All enabled workflows are triggered on each tick with no throttling.

Expected Behavior

The tick endpoint should be rate-limited to prevent rapid repeated calls from exhausting scan quotas, overloading the task queue, or flooding scan targets.

Actual Behavior

Any API key holder can call the tick endpoint without throttling. This bypasses the intended scheduling interval and can force continuous workflow execution.

Root Cause Analysis

The trigger_workflow_tick function was added without the Depends(...) rate limiter pattern used by every other execution endpoint in the file.

Suggested Fix

Add a rate limiter matching the pattern of other execution endpoints:

@router.post("/workflows/scheduler/tick", dependencies=[Depends(tick_limiter)])
async def trigger_workflow_tick():
    await scheduler.tick()
    return {"tick": "ok"}

A reasonable limit is one tick per 10 seconds per API key to allow legitimate external triggers while preventing runaway execution.

Affected File

backend/secuscan/routes.py

Checklist

  • Searched existing issues, not a duplicate
  • Read CONTRIBUTING.md guidelines
  • Provided clear reproduction steps
  • Described expected vs. actual clearly
  • No em dashes or double hyphens
  • Repository verified as GSSoC

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions