SKY-D252 · Security in code
Cookie sent without the Secure or HttpOnly flag
Two cookie flags protect a login cookie. Secure tells the browser to send it only over HTTPS; HttpOnly hides it from page scripts. SKY-D252 reports cookies written with Secure turned off, and in TypeScript, JavaScript and Go also cookies that do not set both flags.
- Languages
- Python, TypeScript/JavaScript, Java, Go, Rust
- Quality gate
- counted toward the gate limits (full and diff scans). Java findings are HIGH, so they also count toward
max_high. - Finding type
- review
- Catalog name
- Insecure cookie
- Go engine ID
- SKY-G221, reported as SKY-D252
Why it matters
A session cookie without Secure is sent in plain text whenever the user opens any http:// link to the site, so anyone on the same Wi-Fi can copy it and take over the session. Without HttpOnly, one cross-site scripting bug can read it with document.cookie.
What Skylos flags
from flask import Flask, make_response, request from app.sessions import create_session app = Flask(__name__) @app.post("/login")def login(): session_id = create_session(request.form["email"], request.form["password"]) response = make_response({"ok": True}) response.set_cookie("sid", session_id, httponly=True, secure=False) return responseWhat Skylos leaves alone
import secrets from flask import Flask, make_response app = Flask(__name__) @app.get("/form")def show_form(): token = secrets.token_urlsafe(32) response = make_response({"csrf": token}) response.set_cookie("csrf_token", token, secure=True, httponly=False) return responseWhy Skylos leaves it alone
This CSRF token cookie is meant to be read by the page's own script, so httponly=False is deliberate, and secure=True keeps it on HTTPS. In Python the rule reports only a literal secure=False.
More languages
TypeScript
Flagged
import express from "express";import { createSession } from "../sessions"; const router = express.Router(); router.post("/login", async (req, res) => { const sessionId = await createSession(req.body.email, req.body.password); res.cookie("sid", sessionId, { httpOnly: true, sameSite: "lax" }); res.json({ ok: true });}); export default router;Not flagged
import express from "express";import { createSession } from "../sessions"; const router = express.Router(); router.post("/login", async (req, res) => { const sessionId = await createSession(req.body.email, req.body.password); const options = { httpOnly: true, secure: true, sameSite: "lax" as const }; res.cookie("sid", sessionId, options); res.json({ ok: true });}); export default router;Why Skylos leaves it alone
The options live in a variable, but Skylos follows it inside the handler and sees httpOnly: true and secure: true, the only combination it accepts for TypeScript and JavaScript.
Java
Flagged
package com.example; import javax.servlet.http.Cookie;import javax.servlet.http.HttpServletResponse; public class LoginController { void remember(HttpServletResponse response, String sessionId) { Cookie cookie = new Cookie("SESSION", sessionId); cookie.setHttpOnly(true); cookie.setSecure(false); response.addCookie(cookie); }}Not flagged
package com.example; import javax.servlet.http.Cookie;import javax.servlet.http.HttpServletResponse; public class ThemeController { void saveTheme(HttpServletResponse response, String theme) { Cookie cookie = new Cookie("theme", theme); cookie.setHttpOnly(false); cookie.setSecure(true); response.addCookie(cookie); }}Why Skylos leaves it alone
A theme cookie that page scripts read needs HttpOnly off, and it holds nothing secret. The Java check reports only cookies whose setSecure() call says false.
Go
Flagged
package app import "net/http" func setSession(w http.ResponseWriter, sessionID string) { http.SetCookie(w, &http.Cookie{ Name: "sid", Value: sessionID, Path: "/", HttpOnly: true, })}Not flagged
package app import "net/http" func setSession(w http.ResponseWriter, sessionID string) { http.SetCookie(w, &http.Cookie{ Name: "sid", Value: sessionID, Path: "/", HttpOnly: true, Secure: true, SameSite: http.SameSiteLaxMode, })}Why Skylos leaves it alone
Both flags are written as true in the http.Cookie literal, which is what the Go check requires.
Rust
Flagged
use cookie::{Cookie, CookieJar};pub fn issue(jar: &mut CookieJar, token: String) { jar.add(Cookie::new("session_id", token));}Not flagged
use cookie::{Cookie, CookieJar};pub fn issue(jar: &mut CookieJar, token: String) { jar.add(Cookie::build(("session_id", token)).secure(true).build());}Why Skylos leaves it alone
The session cookie requires HTTPS.
How Skylos decides
- In Rust, checks the Secure flag when a recognized cookie jar receives a cookie with a session or token name such as
session_idoraccess_token. It follows cookie builders andset_secureon local bindings. It also checks directly returned axum-extra jars and cookies on Actix response builders finalized in the same call chain. Removal cookies, preference cookies and unknown flags stay quiet. - Runs with
--danger. Each language has its own check. - Python: finds
.set_cookie()and.set_signed_cookie()calls with at least a name and a value (Flask, Werkzeug, Django and Starlette share this signature). Reports MEDIUM only whensecureis the literalFalse, by keyword or as the seventh positional argument. A missing,Trueor computed flag is not reported, nor ishttponly=Falseon its own. Test modules are skipped. - TypeScript and JavaScript: finds
.cookie(name, value, options)calls on an HTTP response object, such as theresof an Express route. Options held in a variable in the same function are followed. Reports MEDIUM unless bothhttpOnlyandsecureare known to betrue, so a call with no options, or with options it cannot follow, is reported.express-sessionandcookie-sessionmiddleware is reported when the session cookie'ssecureis missing orfalse(both default to false) orhttpOnlyisfalse;'auto'or a computed value counts as set, and a call inside a development or test branch is skipped. - Java: follows a
Cookiemade withnew Cookie(...). WhensetSecure(...)receives a value known to befalse(a literal or a constant) and the cookie is then passed toaddCookie(), it reports HIGH.setHttpOnlyis not checked. - Go: the Go engine reports a
net/httpCookie{...}literal when eitherHttpOnlyorSecureis absent or proven false, including bounded boolean expressions and immutable constant aliases. A present flag whose runtime value is unknown is not judged. It reports SKY-G221, shown as SKY-D252.
How to fix it
Set secure=True and httponly=True on every session or login cookie, and add samesite="Lax" (or "Strict") so other sites cannot make the browser send it. In local development over plain HTTP, turn Secure off through configuration, not in the code that ships.
from flask import Flask, make_response, request from app.sessions import create_session app = Flask(__name__) @app.post("/login")def login(): session_id = create_session(request.form["email"], request.form["password"]) response = make_response({"ok": True})Removed: response.set_cookie("sid", session_id, httponly=True, secure=False)Added: response.set_cookie(Added: "sid", session_id, httponly=True, secure=True, samesite="Lax"Added: ) return responseWhen it can be wrong
- TypeScript, JavaScript and Go also report harmless cookies that lack
HttpOnlyon purpose, such as a CSRF token or a UI preference the page script reads. - TypeScript and JavaScript: safe options kept in a module-level constant (
const sessionCookie = { httpOnly: true, secure: true }outside the handler) are not followed, so the call is reported with both flags "unknown". - Missed: in Python, a cookie with
secureleft out (Flask then sends it withoutSecureunless configured) and framework settings such asSESSION_COOKIE_SECURE = False. In Java, cookies that never callsetSecure()at all.
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
Mark the reported line and say why the cookie may travel over plain HTTP.
Python response.set_cookie("dev_sid", sid, secure=False) # skylos: ignore[SKY-D252] dev only[tool.skylos] ignore = ["SKY-D252"]turns the rule off for the whole project.skylos baseline .and then--baselineaccept the existing findings and report only new ones.