Skip to main content

SKY-DEP001 · Deployment and infrastructure

Internet-facing route is missing the auth guard your deployment requires

High

Your Kubernetes manifest can declare which guard functions must protect a service's sensitive routes, with the annotation skylos.dev/required-guards. SKY-DEP001 follows the internet-facing Ingress to the Python app it serves and reports an admin, internal, debug or metrics route that lacks one of those guards.

Languages
Python (FastAPI, Flask), Kubernetes YAML
Quality gate
counted toward the gate limits (full and diff scans). Reported under security (danger). It counts toward max_high and max_security.
Finding type
review
Catalog name
Externally deployed route is missing a required auth guard
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

An admin endpoint without its auth check is open to anyone who finds the URL, and /admin paths are the first thing scanners try. Linters cannot see this, because whether a route is reachable from the internet is decided in the deployment files, not in the code.

What Skylos flags

app/main.py · PythonReported on line 13
from fastapi import Depends, FastAPI from app.auth import require_admin app = FastAPI()  @app.get("/health")def health():    return {"ok": True}  @app.get("/admin/users")def list_admin_users():    return {"users": []}
app/auth.py · Python
from fastapi import Header, HTTPException  def require_admin(x_role: str = Header(default="")):    if x_role != "admin":        raise HTTPException(status_code=403)    return x_role
deploy/api.yaml · YAML
apiVersion: apps/v1kind: Deploymentmetadata:  name: api  namespace: prodspec:  selector:    matchLabels:      app: api  template:    metadata:      labels:        app: api      annotations:        skylos.dev/source-file: app/main.py        skylos.dev/required-guards: require_admin    spec:      containers:        - name: api          image: ghcr.io/acme/api:1.4.0          command: ["uvicorn"]          args: ["app.main:app", "--host", "0.0.0.0", "--port", "8000"]          ports:            - name: http              containerPort: 8000---apiVersion: v1kind: Servicemetadata:  name: api  namespace: prodspec:  selector:    app: api  ports:    - name: http      port: 80      targetPort: http---apiVersion: networking.k8s.io/v1kind: Ingressmetadata:  name: api  namespace: prod  annotations:    skylos.dev/network-scope: external    skylos.dev/backend-protocol: httpspec:  rules:    - host: api.example.com      http:        paths:          - path: /            pathType: Prefix            backend:              service:                name: api                port:                  name: http

What Skylos leaves alone

app/main.py · Python
from fastapi import Depends, FastAPI from app.auth import require_admin app = FastAPI()  @app.get("/health")def health():    return {"ok": True}  @app.get("/admin/users")def list_admin_users(user=Depends(require_admin)):    return {"users": []}

app/auth.py: same as in the flagged example.

deploy/api.yaml: same as in the flagged example.

Why Skylos leaves it alone

The same deployment and the same route, now with Depends(require_admin), the guard the manifest requires. /health has no guard either, but it is not a sensitive path.

How Skylos decides

  1. Runs with --danger (or -a). Reads Kubernetes YAML in the repository and only works when an Ingress opts in with the annotations skylos.dev/network-scope: external (or internet, public) and skylos.dev/backend-protocol: http.
  2. Follows one chain inside one YAML file: Ingress path, to the Service and port it names, to the one workload the Service selects, to the one container whose port the Service targets. The server must be started with a literal command and args (uvicorn, gunicorn, flask run, or python -m one of them) bound to 0.0.0.0 or :: on that port.
  3. Any missing, dynamic or ambiguous link (two matching workloads, a Helm template value, HTTPS or gRPC backends, rewrite or snippet annotations) makes it report nothing rather than guess.
  4. The workload's pod template must also carry skylos.dev/source-file (the Python file the server's module:app target names) and skylos.dev/required-guards (a comma-separated list of guard names).
  5. In that file it reads the top-level FastAPI or Flask routes of the app object. A route counts as sensitive when its path, as reached through the Ingress, has a segment such as admin, internal, debug, manage, metrics or pprof.
  6. A guard counts only under its exact name: in the app's or the route's dependencies, as a Depends(...) parameter, or as a decorator on the handler. A check inside the function body does not count.
  7. Reports HIGH on the route's decorator line, naming the missing guards.

How to fix it

Add the required guard to the route, as a dependency or a decorator, so the contract in the manifest holds.

app/main.py · Python · the fix, against the flagged file
from fastapi import Depends, FastAPI from app.auth import require_admin app = FastAPI()  @app.get("/health")def health():    return {"ok": True}  @app.get("/admin/users")Removed: def list_admin_users():Added: def list_admin_users(user=Depends(require_admin)):    return {"users": []}

When it can be wrong

  • Routes added through nested routers (include_router, blueprints) or factory functions are not checked.
  • It checks that the guard is wired in, not what the guard does.
  • Without the two Ingress annotations the rule never runs. Keep them in a protected place: removing them silences the rule.
  • Resources split across several YAML files, Helm charts and Kustomize overlays are not joined or rendered. Scan rendered manifests.

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

  • Put the marker on the reported decorator line.

    Python
    @app.get("/admin/users")  # skylos: ignore[SKY-DEP001] VPN only
  • [tool.skylos] ignore = ["SKY-DEP001"] turns the rule off for the project.

  • A baseline (skylos baseline ., then --baseline) accepts the findings that exist today and reports new ones.

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