Skip to content

Commit c6a0710

Browse files
committed
Don't allow passing tokens in query parameters
1 parent 38a63f6 commit c6a0710

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

gefapi/routes/api/v1/executions.py

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -98,36 +98,41 @@ def run_script(script):
9898
"""
9999
logger.info("[ROUTER]: Running script: " + script)
100100
user = current_user
101+
102+
# Security: Reject token query parameter usage (CWE-598)
103+
# Tokens in URLs are logged in server logs, browser history, and referrer headers
104+
if request.args.get("token"):
105+
import rollbar
106+
107+
rollbar.report_message(
108+
"SECURITY ERROR: Rejected token query parameter in script execution "
109+
f"request for script '{script}' by user '{user.email}'. Token-based "
110+
"authentication via query parameters is not supported. Use "
111+
"Authorization header instead.",
112+
level="error",
113+
extra_data={
114+
"script": script,
115+
"user_id": str(user.id),
116+
"user_email": user.email,
117+
"endpoint": "run_script",
118+
"security_issue": "CWE-598",
119+
"client_ip": request.remote_addr,
120+
},
121+
)
122+
logger.error(
123+
f"[SECURITY]: Rejected token query parameter from {user.email} "
124+
f"for script {script}. CWE-598 violation."
125+
)
126+
return error(
127+
status=400,
128+
detail="Token authentication via query parameters is not supported. "
129+
"Use the Authorization header with a Bearer token instead.",
130+
)
131+
101132
try:
102133
params = request.args.to_dict() if request.args else {}
103134
if request.get_json(silent=True):
104135
params.update(request.get_json())
105-
if "token" in params:
106-
# Security: Log deprecated token query parameter usage
107-
# Tokens in URLs are logged in server logs, browser history, and referrer
108-
# headers, which is a security risk (CWE-598)
109-
import rollbar
110-
111-
rollbar.report_message(
112-
"SECURITY WARNING: Deprecated token query parameter used in "
113-
f"script execution request for script '{script}' by user "
114-
f"'{user.email}'. Token-based authentication via query "
115-
"parameters is deprecated and will be removed in a future "
116-
"version. Use Authorization header instead.",
117-
level="warning",
118-
extra_data={
119-
"script": script,
120-
"user_id": str(user.id),
121-
"user_email": user.email,
122-
"endpoint": "run_script",
123-
"security_issue": "CWE-598",
124-
},
125-
)
126-
logger.warning(
127-
f"[SECURITY]: Deprecated token query parameter used by {user.email} "
128-
f"for script {script}. This should be migrated to header-based auth."
129-
)
130-
del params["token"]
131136
execution = ExecutionService.create_execution(script, params, user)
132137
except ScriptNotFound as e:
133138
logger.error("[ROUTER]: " + e.message)

0 commit comments

Comments
 (0)