SKY-L012 · AI-code defects
Phantom symbol reference
A phantom symbol is a function, class or name that the code uses but that does not exist where the code says it lives: auth.verify_token() when the project's auth module only defines verify_access_token. SKY-L012 checks each reference into the project's own modules, and into a few installed packages, against what those modules really define.
- Languages
- Python, Go, Java, TypeScript, JavaScript
- Turned on by
skylos . --ai-defects(or-a); reads the code as it is, no diff needed- Quality gate
- counted toward the gate limits; a CRITICAL finding fails the gate on its own (full and diff scans). Counts toward
max_ai_defects. Every finding is CRITICAL, andblock_ai_defect_severities(under[tool.skylos.gate]) is["CRITICAL"]by default, so one finding fails the gate on its own. The agent hook (skylos verify) also blocks on it. - Finding type
- review
Why it matters
Coding agents guess helper names that sound right. In Python the guess fails only when that line runs, often on the error path or in the security check nobody exercised, and a missing verify_token can crash the endpoint it was meant to protect. In Go, Java and TypeScript the build breaks, but only after the change has been written and reviewed.
What Skylos flags
"""Token checks for the API.""" import hashlibimport hmac def verify_access_token(token, secret): body, _, signature = token.rpartition(".") expected = hmac.new(secret, body.encode(), hashlib.sha256).hexdigest() return hmac.compare_digest(expected, signature)from app import auth def get_invoice(request, invoice_id, secret): if not auth.verify_token(request.headers["Authorization"], secret): return {"status": 401} return {"status": 200, "invoice": invoice_id}What Skylos leaves alone
from app import auth def get_invoice(request, invoice_id, secret): header = request.headers["Authorization"] if not auth.verify_access_token(header, secret): return {"status": 401} return {"status": 200, "invoice": invoice_id}Why Skylos leaves it alone
The view calls the helper that app/auth.py really defines. Skylos resolves auth to the local module, finds verify_access_token among its top-level names and has nothing to report.
More languages
Go
Flagged
module example.com/shop go 1.22package auth import "strings" func VerifyAccessToken(header string) bool { return strings.HasPrefix(header, "Bearer ") && len(header) > 7}package api import ( "net/http" "example.com/shop/auth") func GetInvoice(w http.ResponseWriter, r *http.Request) { if !auth.VerifyToken(r.Header.Get("Authorization")) { w.WriteHeader(http.StatusUnauthorized) return } w.WriteHeader(http.StatusOK)}Not flagged
package api import ( "net/http" "example.com/shop/auth") func GetInvoice(w http.ResponseWriter, r *http.Request) { if !auth.VerifyAccessToken(r.Header.Get("Authorization")) { w.WriteHeader(http.StatusUnauthorized) return } w.WriteHeader(http.StatusOK)}Why Skylos leaves it alone
example.com/shop/auth is a package of this module (go.mod), and it exports VerifyAccessToken. The flagged version names VerifyToken, which the package does not declare; the finding lists the close match.
TypeScript
Flagged
export function verifyAccessToken(header: string): boolean { return header.startsWith("Bearer ") && header.length > 7;}import { verifyToken } from "../auth/token"; export function getInvoice(headers: Record<string, string>, id: string) { if (!verifyToken(headers["authorization"])) { return { status: 401 }; } return { status: 200, id };}Not flagged
import { verifyAccessToken } from "../auth/token"; export function getInvoice(headers: Record<string, string>, id: string) { if (!verifyAccessToken(headers["authorization"])) { return { status: 401 }; } return { status: 200, id };}Why Skylos leaves it alone
The import names an export that src/auth/token.ts really has. In TypeScript and JavaScript the finding sits on the import line, where the missing name is first requested.
How Skylos decides
- Python: builds a table of every module in the project and the names each one defines at top level, imports or re-exports. It then follows each
from app.auth import name,auth.name(...),auth.nameand@auth.namein the scanned files to the local module it points at, and reports the reference when that module has no such name. Decorators are reported as SKY-L023 instead. - Python, stays silent when the name may exist: the target module has a module-level
__getattr__or otherwise writes its own namespace, the name is bound only in some branches, the reference sits under atry/except AttributeError(orImportErrorfor imports), or it is only used for type checking and the module defines it there. - Python, bare calls: a call to a name that is not bound anywhere in scope is reported when it closely resembles a function elsewhere in the project (a stale name after a rename). A separate check reports a bare call to a well-known security helper name, such as
sanitize_input()orverify_token(), that the file neither defines nor imports. - Python, installed packages: for the packages the API signature check inspects (
requests,pandas,boto3,openai,jwt, orapi_signature_modules), an import of a submodule that the installed package does not have, such asfrom requests.retry import Retry, is reported under this rule too. - Go: resolves imports of packages in the same module (from
go.mod) and reportspkg.Namewhen that package does not declare an exportedName. Java: checks references to the project's own classes and static members. TypeScript and JavaScript: checks named imports from relative project files against what those files export. Each finding lists close matches when there are any.
How to fix it
Call the helper that really exists, or write the missing one in the module the code imports it from. Do not silence the finding by catching the resulting AttributeError: the check would still never run.
from app import auth def get_invoice(request, invoice_id, secret):Removed: if not auth.verify_token(request.headers["Authorization"], secret):Added: header = request.headers["Authorization"]Added: if not auth.verify_access_token(header, secret): return {"status": 401} return {"status": 200, "invoice": invoice_id}When it can be wrong
- A module that adds names at run time in a way Skylos cannot follow, for example a plugin loader that calls
setattr()on another module with a computed name, can make a real name look missing. - A bare call to a security-helper name such as
sanitize_input()is reported when the name comes from a star import of an installed package or abuiltinspatch, because the file neither defines nor imports it by name. - To add your own helper names to the security list, set
extra_phantom_namesunder[tool.skylos.vibe].
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 reported line, with the reason the name exists at run time:
Python if not auth.verify_token(header, secret): # skylos: ignore[SKY-L012] plugin adds it[tool.skylos] ignore = ["SKY-L012"]turns the rule off for the project.