Skip to main content

SKY-F102 · Quality, structure and performance

Route that changes data without an auth guard

Varies

The catalog gives no severity. A mutating route with no visible guard is MEDIUM; a FastAPI route whose ownership check does not protect the object it returns or changes is HIGH.

A route that changes data (PUT, PATCH, DELETE, or a POST that is not a plain query) should check who is calling. SKY-F102 reports such a Python web route when nothing on it shows an authentication or permission guard. It is a review: the guard may live somewhere Skylos cannot see.

Languages
Python
Quality gate
counted toward the gate limits (full and diff scans). Listed by default and counted toward max_quality. A scan with security checks (--danger, -a) replaces it with SKY-D283 when the route performs a privileged action such as a delete.
Finding type
review
Catalog name
Framework route missing auth
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Without a guard, anyone who can reach the server can change another customer's shipping address, cancel orders or edit settings, just by sending the request with a different ID.

What Skylos flags

app/api/orders.py · PythonReported on line 17
"""Order API.""" from fastapi import FastAPIfrom pydantic import BaseModel from app.db import save_address app = FastAPI()  class Address(BaseModel):    street: str    city: str  @app.put("/orders/{order_id}/address")def update_address(order_id: int, address: Address) -> dict:    save_address(order_id, address)    return {"updated": order_id}

What Skylos leaves alone

app/api/orders.py · Python
"""Order API.""" from fastapi import Depends, FastAPIfrom pydantic import BaseModel from app.auth import User, get_current_userfrom app.db import save_address app = FastAPI()  class Address(BaseModel):    street: str    city: str  @app.put("/orders/{order_id}/address")def update_address(    order_id: int, address: Address, user: User = Depends(get_current_user)) -> dict:    save_address(order_id, address, owner_id=user.id)    return {"updated": order_id}

Why Skylos leaves it alone

The route takes the caller from Depends(get_current_user), a dependency whose name reads as authentication, and passes the user's ID on, so the update is limited to the caller's own orders.

How Skylos decides

  1. Runs with --quality, on Python files outside test and tests folders and test_*.py or *_test.py files. Covers route decorators of FastAPI, Flask, Quart, Starlette and Sanic style (@app.put(...), @router.delete(...), @bp.route(..., methods=["POST"])).
  2. A route changes data when it accepts PUT, PATCH or DELETE, or POST unless its name or path reads as a query (search, lookup, calculate, ...) and its body changes nothing.
  3. It counts as guarded when another decorator's name reads as auth (login_required, requires_permission), the route passes dependencies=[Depends(...)], its router was created with a guard, a parameter's name or type reads as auth (token, current_user, principal), or a default calls such a dependency.
  4. Reports MEDIUM on the def line when no guard is found. It also reports HIGH for a FastAPI route that compares an owner or tenant ID but returns or changes an object that comparison does not protect.

How to fix it

Require the caller as a dependency (Depends(get_current_user)), or add a guard to the router with dependencies=[...], and check that the caller owns the object it changes.

app/api/orders.py · Python · the fix, against the flagged file
"""Order API.""" Removed: from fastapi import FastAPIAdded: from fastapi import Depends, FastAPIfrom pydantic import BaseModel Added: from app.auth import User, get_current_userfrom app.db import save_address app = FastAPI()  class Address(BaseModel):    street: str    city: str  @app.put("/orders/{order_id}/address")Removed: def update_address(order_id: int, address: Address) -> dict:Removed:     save_address(order_id, address)Added: def update_address(Added:     order_id: int, address: Address, user: User = Depends(get_current_user)Added: ) -> dict:Added:     save_address(order_id, address, owner_id=user.id)    return {"updated": order_id}

When it can be wrong

  • A guard applied elsewhere, such as middleware, a gateway in front of the app or a router mounted with dependencies in another module, is not seen, so the route is reported.
  • A guard is recognised by name: a dependency called get_current_user counts, while one called get_caller does not, and a parameter named token counts even when it is never checked.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • On the def line (the reported line):

    Python
    def update_address(order_id: int, address: Address) -> dict:  # skylos: ignore[SKY-F102]
  • [tool.skylos] ignore = ["SKY-F102"] turns the rule off for the project. Neither silences SKY-D283. A baseline accepts existing findings, but it records the absolute file path and the line, so an entry stops matching when the checkout moves or the line shifts.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.