Skip to main content

SKY-L021 · Logic and resilience

Security control removed by a change

High

The catalog gives no severity for this rule; every finding is HIGH.

SKY-L021 compares each changed source file with its earlier version and reports a security control that the change takes away: a login decorator, an auth dependency, CSRF protection, TLS verification, a validation or escaping call, a security header and similar checks. It looks at the change, not at the code as a whole.

Languages
Python, TypeScript, JavaScript, Go, Java, PHP, Rust, Dart
Turned on by
skylos . --quality --diff origin/main (or --danger, or -a); a full scan also checks uncommitted changes.
Quality gate
fails the gate on its own (full and diff scans). It is only reported when the scan compares the code with an earlier version: a --diff scan, uncommitted or staged changes in a Git checkout, or a CI run that names a base branch. A HIGH finding fails the gate whatever the limits, and a baseline cannot accept it.
Finding type
review
Catalog name
Security regression
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Removing one decorator is a one-line diff that looks like cleanup, but it opens the endpoint to anyone. Coding agents do this when a test fails with a 302 or 403 and the quickest way to pass is to drop the check.

What Skylos flags

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

billing/views.py · Python · changed
"""Refunds for the customer billing pages.""" Removed: from django.contrib.auth.decorators import login_requiredfrom django.http import JsonResponsefrom django.shortcuts import get_object_or_404 from billing.models import Invoice  Removed: @login_requireddef refund_invoice(request, invoice_id):    invoice = get_object_or_404(Invoice, pk=invoice_id)    invoice.refund(issued_by=request.user)    return JsonResponse({"status": "refunded", "id": invoice.pk})

What Skylos leaves alone

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

billing/views.py · Python · changed
"""Refunds for the customer billing pages.""" Removed: from django.contrib.auth.decorators import login_requiredAdded: from django.core.exceptions import PermissionDeniedfrom django.http import JsonResponsefrom django.shortcuts import get_object_or_404 from billing.models import Invoice  Removed: @login_requireddef refund_invoice(request, invoice_id):Added:     if not request.user.is_authenticated:Added:         raise PermissionDenied    invoice = get_object_or_404(Invoice, pk=invoice_id)    invoice.refund(issued_by=request.user)    return JsonResponse({"status": "refunded", "id": invoice.pk})

Why Skylos leaves it alone

The decorator is gone, but the view now starts with a check that rejects anonymous users. Skylos proves this one replacement: Django's own login_required swapped for a first-statement if not request.user.is_authenticated: that raises Django's PermissionDenied or returns a 401/403 response.

How Skylos decides

  1. Runs with --quality or --danger when Git reports changed files: in a --diff scan, and in a full scan for uncommitted or staged work, or against the base branch that SKYLOS_DIFF_BASE or the CI provider names. Compares every changed .py, .ts, .tsx, .js, .jsx, .go, .java, .php, .rs and .dart file with its version at the base. New and deleted files are skipped, and so are files whose path has a test, tests or __tests__ folder or a test file name.
  2. In Python, parses both versions of each top-level function. Reports an auth decorator (login_required, permission_required, jwt_required, admin_required and names such as require_admin or staff_only) that was removed, and a Django if not request.user.is_authenticated guard that was removed. Stays quiet when the whole function was deleted, or when Django's login_required was replaced by such a guard or kept in another form.
  3. For other code, reads the removed and added lines: a removed auth, validation, audit, permission or rate-limit decorator; a removed Depends(get_current_user)-style auth dependency or auth-typed parameter that the change does not add back; removed CSRF protection or an added @csrf_exempt; an added verify=False; sha256 and similar replaced by md5 or sha1.
  4. Also reports removed validate(, escape( and sanitising calls the change does not add back, removed Django or DRF validators, security headers such as Content-Security-Policy, header middleware (helmet(, SecurityMiddleware), encrypt(/Fernet calls, SECRET_KEY assignments, audit logging and permission checks.
  5. For routes, reports auth middleware removed from an Express route that still exists, and an if that compares the owner or current user and rejects with 401/403 when it is removed from a function that still exists.
  6. Each finding is HIGH and points at a line of the new file next to where the control used to be (for a Python decorator, the def line). Diff filtering keeps it even though that line did not change.

How to fix it

Put the control back. If the view moved to a different check on purpose, make that check reject the caller before any work is done, and say so in the pull request.

Fix · Python
@login_requireddef refund_invoice(request, invoice_id):    invoice = get_object_or_404(Invoice, pk=invoice_id)

When it can be wrong

  • A control replaced by an equivalent one Skylos cannot prove, such as a Flask before_request hook, a class-level permission or a custom middleware, is still reported. Only the Django replacement in the not-flagged example is recognised.
  • Most checks match text on removed lines, so moving a validate( call or a header line into another file of the same change is reported as a removal.
  • Product issue: the test-file check reads the absolute path, so when the repository itself sits under a folder named test, tests or __tests__ (for example /home/ci/tests/shop), nothing is reported.

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

  • An inline # skylos: ignore[SKY-L021] marker does not hide it: inline markers are applied before this comparison runs. A baseline does not either; every removed control counts as new.

    Python
    def refund_invoice(request, invoice_id):  # skylos: ignore[SKY-L021] ignored
  • [tool.skylos] ignore = ["SKY-L021"] turns the comparison off for the project.

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