Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ This project is a simple banking application with multiple security vulnerabilit
- Directory traversal
- No file size limits
- Unsafe file naming
- Insecure deserialization

5. **Session Management**
- Token vulnerabilities
Expand Down Expand Up @@ -323,6 +324,7 @@ The application uses PostgreSQL. The database will be automatically initialized
3. Upload oversized files
4. Test file overwrite scenarios
5. File type bypass
6. Insecure deserialization

### API Security Testing
1. Token manipulation
Expand Down
18 changes: 14 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from datetime import datetime, timedelta
import random
import string
import pickle
import html
import os
from dotenv import load_dotenv
Expand Down Expand Up @@ -525,12 +526,11 @@ def get_transaction_history(account_number):
def upload_profile_picture(current_user):
if 'profile_picture' not in request.files:
return jsonify({'error': 'No file provided'}), 400

file = request.files['profile_picture']

file = request.files['profile_picture']
if file.filename == '':
return jsonify({'error': 'No file selected'}), 400

try:
# Vulnerability: No file type validation
# Vulnerability: Using user-controlled filename
Expand All @@ -543,9 +543,19 @@ def upload_profile_picture(current_user):

# Vulnerability: Path traversal possible if filename contains ../
file_path = os.path.join(UPLOAD_FOLDER, filename)

file.save(file_path)

# NEW VULNERABILITY: Insecure deserialization
# Attempt to deserialize the uploaded file using pickle.load()
# regardless of file extension or content
try:
file.seek(0) # Reset file pointer to beginning
deserialized_data = pickle.load(file)
print(f"Deserialized data: {deserialized_data}")
except Exception as pickle_error:
# Continue execution even if deserialization fails
print(f"Pickle deserialization failed: {str(pickle_error)}")

# Update database with just the filename
execute_query(
"UPDATE users SET profile_picture = %s WHERE id = %s",
Expand Down