Share
## https://sploitus.com/exploit?id=CADE3C59-99E9-5C0B-A9D0-26580AB03B40
# Class04: Fixing Cross-Origin Vulnerabilities and Business Logic Issues

> **Project Name:** Class04-Authorization-BusinessLogic-Fix  
> **Date:** 2026-07-21  
> **Repository URL:** `github.com/fankfc/Class04-Authorization-BusinessLogic-Fix`

---

## Project Overview

This project is a Flask-based user management platform. In addition to login, registration, search, and avatar upload features, new **personal center and recharge functions** have been added. These new features require comprehensive **cross-origin vulnerabilities fixes** and **business logic fixes**. 

## Fixed Vulnerabilities

### Cross-Origin Vulnerabilities

| Vulnerability | Before Fix | After Fix |
|--------------|-------------|------------|
| Unauthorized access to profile data | No need to log in; ?user_id=X allows viewing any user's data | Only logged-in users can view their own data |

### Business Logic Vulnerabilities

| Vulnerability | Before Fix | After Fix |
|--------------|-------------|------------|
| Recharging negative amounts | `amount=-500` reduces balance | Only positive amounts are allowed |
| Unlimited recharge | `amount=999999999` succeeds | Limit: 1,000,000 |
| No CSRF protection | Directly posting to modify balance | Requires a valid CSRF Token |
| Unlimited recharge attempts | Batch balance updates possible | Limit: 3 times per minute |
| Balances not persisted | Resets after restart | Persisted by SQLite |

## Feature List

| Feature | Route | Description |
|------|------|------|
| Home Page | `GET /` | Displays user information / searches for users |
| Login | `GET+POST /login` | CSRF + rate limiting + account locking |
| Registration | `GET+POST /register` | Parameterized queries to prevent SQL injection |
| Search | `GET /search` | Parameterized LIKE queries |
| Avatar Upload | `GET+POST /upload` | 4-tier security protection (requires login) |
| Personal Center | `GET /profile` | Views personal information (requires login, prevents cross-origin attacks) |
| Recharge | `POST /recharge` | CSRF + positive/negative validation + limit on amount and speed (requires login) |
| Logout | `GET /logout` | Clears the session |

## Quick Start

```bash
pip install flask Pillow
python app.py
# Visit http://localhost:5000
```