Last active
June 22, 2024 13:59
-
-
Save RiccardoBiosas/e5a43cdd58699d6c2e9f3372281f3a05 to your computer and use it in GitHub Desktop.
Web API Remote Code Execution (RCE) example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask, request, jsonify | |
| app = Flask(__name__) | |
| @app.route('/hack-me', methods=['POST']) | |
| def evaluate_expression(): | |
| try: | |
| user_input = request.json.get('expression') | |
| ## UNSAFE | |
| result = eval(user_input) | |
| return jsonify({'result': result}) | |
| except Exception as e: | |
| return jsonify({'error': str(e)}), 400 | |
| if __name__ == '__main__': | |
| app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment