SKY-L021 · Logic and resilience
Security control removed by a change
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
--diffscan, 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
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
"""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
"""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
- Runs with
--qualityor--dangerwhen Git reports changed files: in a--diffscan, and in a full scan for uncommitted or staged work, or against the base branch thatSKYLOS_DIFF_BASEor the CI provider names. Compares every changed.py,.ts,.tsx,.js,.jsx,.go,.java,.php,.rsand.dartfile with its version at the base. New and deleted files are skipped, and so are files whose path has atest,testsor__tests__folder or a test file name. - In Python, parses both versions of each top-level function. Reports an auth decorator (
login_required,permission_required,jwt_required,admin_requiredand names such asrequire_adminorstaff_only) that was removed, and a Djangoif not request.user.is_authenticatedguard that was removed. Stays quiet when the whole function was deleted, or when Django'slogin_requiredwas replaced by such a guard or kept in another form. - 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 addedverify=False;sha256and similar replaced bymd5orsha1. - Also reports removed
validate(,escape(and sanitising calls the change does not add back, removed Django or DRF validators, security headers such asContent-Security-Policy, header middleware (helmet(,SecurityMiddleware),encrypt(/Fernetcalls,SECRET_KEYassignments, audit logging and permission checks. - For routes, reports auth middleware removed from an Express route that still exists, and an
ifthat compares the owner or current user and rejects with 401/403 when it is removed from a function that still exists. - 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
defline). 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.
@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_requesthook, 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,testsor__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.