SecureBank is a small, security-focused banking web application built for an application security course. It is split into a FastAPI backend and a static HTML/CSS/JavaScript frontend. The system demonstrates core banking flows (authentication, accounts, transactions) with security features such as JWT-based sessions, MFA, rate limiting, and audit logging.
-
Frontend : [HTML, CSS, Vanilla JavaScript]
-
Backend :
- Language: Python
- Web framework: FastAPI
- ASGI server: Uvicorn
- Database: PostgreSQL
- ORM: SQLAlchemy
- Migrations: Alembic
- Data validation: Pydantic, pydantic-settings
- Auth & security: JWT (python-jose), bcrypt, cryptography (AES-256)
- MFA/TOTP: pyotp, qrcode
- Rate limiting: slowapi
- Utilities: python-dotenv, python-multipart
- User Login
- Role-based access: Admin/User
- Authentication with JWT access tokens.
- Optional MFA (TOTP) for sensitive actions or thresholds.
- Account and transaction management endpoints.
- Admin and auditor views with dedicated pages.
- Audit log access for monitoring and compliance.
- Security headers and CORS controls at the API layer.
- Rate limiting and lockout logic for failed logins.
- STRIDE & DREAD security modeling
- Code scanning using CodeQL,Bandit
-
Input Validation: Pydantic schemas with field validators for email, password rules, OTP, and amounts.
-
Output Sanitization: Transfer note sanitization strips HTML before storage.
-
Password Hashing: bcrypt for password hashing and verification.
-
Encryption: AES-256-CBC for sensitive fields (balances, amounts).
-
Session Management: JWT access tokens with expiry, refresh tokens stored as HttpOnly cookies, and token blacklist on logout.
-
Headers: CSP, HSTS, X-Frame-Options, X-Content-Type-Options, and other security headers set in the API middleware.
-
CORS and rate limiting setup: CORS allowlist plus SlowAPI rate limiting.
-
Role-based Authorization: Role checks enforced via middleware dependencies (Customer/Manager/Auditor).
See docs/STRIDE Threat Model.md
See docs/DREAD Risk Assessment.md
- GitHub CodeQL
- Bandit
Reports/screenshots are included in the scans/ directory.
Instructions:
sudo apt install postgresql postgresql-contrib -yInstall from requirements.txt with this command :
pip install --break-system-packages -r requirements.txtin setting.py please set in "env_file" : ".env",
Data base : sudo service postgresql start
add test data on it : run python SRC\securebank-python\seed.py
backend : uvicorn main:app --reload --port 5000 --host 0.0.0.0
in SRC\securebank-python
Frontend : python -m http.server 8000 --bind 0.0.0.0
in SRC\securebank-frontend