SKY-A105 · AI-code defects
Contract route guard missing
An AI contract (.skylos/ai-contract.yml) is a file where a team writes down rules for code agents. Its security.routes section names the folders that hold web routes and the decorators that guard them, such as login_required. SKY-A105 reports a route in those folders that has none of the named guards.
- Languages
- Python (Flask, FastAPI and other decorator-routed frameworks)
- Turned on by
skylos verify .orskylos verify --diffwith a contract in.skylos/ai-contract.yml- Quality gate
- not checked (full and diff scans). No
skylos .scan reports it.skylos verifyreports it and exits 1 (unless--no-fail), and the agent edit hook, which runs the same check, blocks the agent on it. - Needs
- A
.skylos/ai-contract.ymlcontract that lists route folders undersecurity.routes.pathsand guard decorators undersecurity.routes.require_any_decorator. - Finding type
- review
Why it matters
A route without its login or permission decorator is open to anyone who can reach the server. Agents often copy a neighbouring route and drop the decorator, and the endpoint still works in every manual test.
What Skylos flags
from flask import Blueprint, jsonifyfrom flask_login import login_required from apps.api.store import load_invoice, refund_invoice bp = Blueprint("invoices", __name__) @bp.get("/invoices/<int:invoice_id>")@login_requireddef show_invoice(invoice_id): return jsonify(load_invoice(invoice_id)) @bp.post("/invoices/<int:invoice_id>/refund")def refund(invoice_id): return jsonify(refund_invoice(invoice_id))version: 1 security: routes: paths: - "apps/api/**" require_any_decorator: - login_requiredWhat Skylos leaves alone
from flask import Blueprint, jsonify bp = Blueprint("status", __name__) @bp.get("/status")def status(): return jsonify({"ok": True})Why Skylos leaves it alone
The status route has no guard, but it lives in apps/public/, outside the folders the contract names. The contract decides which routes must be guarded; public health checks are left to it.
More languages
Python
Flagged
from fastapi import APIRouter from apps.api.store import refund_invoice router = APIRouter() @router.post("/invoices/{invoice_id}/refund")def refund(invoice_id: int): return refund_invoice(invoice_id)version: 1 security: routes: paths: - "apps/api/**" require_any_decorator: - login_requiredNot flagged
from fastapi import APIRouter, Depends from apps.api.auth import login_requiredfrom apps.api.store import refund_invoice router = APIRouter() @router.post( "/invoices/{invoice_id}/refund", dependencies=[Depends(login_required)],)def refund(invoice_id: int): return refund_invoice(invoice_id)Why Skylos leaves it alone
There is no guard decorator, but the route's dependencies= names login_required. A guard passed through dependencies or dependency_overrides of the route decorator counts.
How Skylos decides
- Runs only in
skylos verify(and the agent edit hook that uses it), and only when a contract is found:--contract PATH, or.skylos/ai-contract.ymlin the target folder or one of its parents. The contract must list bothsecurity.routes.pathsandsecurity.routes.require_any_decorator. - Reads the
.pyfiles that match the contract's paths (a folder name, a glob, orfolder/**), or only the changed or chosen file whenskylos verifychecks one file. Files that cannot be read or parsed are listed as unchecked. - Finds functions with a route decorator: a dotted call such as
bp.get,app.post,router.putorrouter.websocket(route,get,post,put,patch,delete,api_route,websocket), or a barerouteorapi_route. - A route passes when one of its decorators has a required name (with or without
@, call brackets or a module prefix), or when the route decorator'sdependencies=ordependency_overrides=mentions one. - Reports each route that has none, at its
defline, naming the route path and the decorators the contract accepts. It checks that a decorator is present, not that it really authenticates.
How to fix it
Add the guard the contract asks for. If the route really must be public, move it out of the guarded folders, or narrow the contract's paths, in a change a person reviews.
@bp.post("/invoices/<int:invoice_id>/refund")@login_requireddef refund(invoice_id): return jsonify(refund_invoice(invoice_id))When it can be wrong
- A route guarded some other way, by a blueprint-wide
before_requestcheck, middleware or a guard with a name the contract does not list, is reported. List that guard's name inrequire_any_decorator. - Any decorated function whose decorator ends in
.get,.postand so on counts as a route, so a non-web helper decorated with, say,cache.getinside a guarded folder is reported. - A decorator with a required name passes even if it does nothing; the rule checks presence, not behaviour.
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
Change the contract: narrow
security.routes.pathsso it leaves out the folder, or add the guard you use torequire_any_decorator.skylos verify --no-contractskips every contract check for one run.In Skylos 5.6.0 neither
# skylos: ignore[SKY-A105]on thedefline nor[tool.skylos] ignore = ["SKY-A105"]silences it: the route check runs after those filters.