SKY-F102 · Quality, structure and performance
Route that changes data without an auth guard
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
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
"""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
"""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
- Runs with
--quality, on Python files outsidetestandtestsfolders andtest_*.pyor*_test.pyfiles. Covers route decorators of FastAPI, Flask, Quart, Starlette and Sanic style (@app.put(...),@router.delete(...),@bp.route(..., methods=["POST"])). - 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. - It counts as guarded when another decorator's name reads as auth (
login_required,requires_permission), the route passesdependencies=[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. - Reports MEDIUM on the
defline 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.
"""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_usercounts, while one calledget_callerdoes not, and a parameter namedtokencounts 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
defline (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.