[# π VulnerableECommerceMVC Lab β π
Author: Paul Volosen, CISSP
GitHub: paul007ex/vulnEcommMVC
LinkedIn: paulvolosen
- Lab Overview
- Learning Outcomes
- Prerequisites & Setup
- Project Structure
- Phase Walkthrough
- Use-Case Deep Dives
- Threat Modeling & Compliance
- Attack & Test Matrix
- Extension Ideas
- Resources & Further Reading
- Feedback & Contributing
This hands-on lab simulates legacy auth mistakes and modern remediations in a .NET MVC app.
You will clone, compile, attack, fix, and map everything to real-world frameworks:
β’ STRIDE threat model
β’ NIST SSDF
β’ OWASP SAMM
β’ PCI-DSS v4.0
β’ ISO 27001:2022
β’ GDPR/CCPA
By completing this lab, you will be able to:
- π Identify and exploit common auth flaws
- π Validate and secure redirect endpoints
- π Migrate from Basic-Auth β SHA-256 β HMAC
- π‘οΈ Map fixes to security standards & compliance
- π Build a repeatable attack/test matrix
- π§ Extend to modern SSO (SAML/OIDC) demos
-
Install
- .NET 7 SDK & Runtime
git,curl, PowerShell (Windows) / Bash (macOS/Linux)
-
Clone & Run
git clone https://github.com/paul007ex/vulnEcommMVC.git cd vulnEcommMVC dotnet restore dotnet run -
Verify
- App:
http://localhost:5000 - Swagger UI (if enabled):
http://localhost:5000/swagger
- App:
π¦ vulnEcommMVC
β£ π Program.cs
β£ π DataStore.cs β In-memory βSQLβ tables
β£ π User.cs β Model + roles
β£ π Controllers/
β β£ π HomeController.cs β Insecure Basic-Auth over HTTP
β β£ π SecureLoginController.csβ HTTPS + SHA-256
β β£ π LoginController.cs β MVC Form login (no CSRF!)
β β£ π RedirectController.cs β Blind-redirect demo
β β π HmacController.cs β HMAC signature demo
β£ π tests.sh β curl attack & validation scripts
β£ π INSTRUCTIONS.md β This master README source
β π Explanation-*.md β Per-feature deep dives
1) Hello World Console β helloworld.cs
2) Minimal HTTP Server β Program.cs
3) In-Memory Data Store β DataStore.cs + User.cs
4) Use-Case #1: Open Redirect
5) Use-Case #2: Basic-Auth Leak
6) Use-Case #3: Base64 Misuse β HMAC
Vulnerability: Unvalidated
returnUrlparameter allows phishing & credential capture.
curl -v "http://localhost:5000/redirect?to=https://evil.com"ASCII Flow β Before
βββββββββββ GET /redirect?to=https://evil.com βββββββββββββββββββββ
β Browser β βββββββββββββββββββββββββββββββββββββββΊ β RedirectController β
βββββββββββ β no validation β
βββββββββββββββββββββ
β
βΌ
302 Location=https://evil.com
Remediation Fix:
if (!IsAllowedDomain(returnUrl))
return BadRequest("Invalid redirect");
return Redirect(returnUrl);Vulnerability: HTTP Basic Auth over plaintext reveals Base64-encoded creds.
curl -v -u admin:password http://localhost:5000/secure/basicASCII Flow
Browser βββΆ βAuthorization: Basic QWxhZGRpbjpPcGVuU2VzYW1lβ
β decode
HomeController βββΊ Compare plaintext vs. DataStore
Remediation Fixes:
- Enforce HTTPS only
- Migrate credentials to SHA-256 hashing
- Implement rate limiting & account lockouts
Vulnerability: Base64 βsignatureβ is trivially forgeable β payload tampering.
GET /cart/add?item=123&sig=MTIzCg==
# Change item β 999, recalc Base64
curl "http://localhost:5000/cart/add?item=999&sig=$(echo -n '999' | base64)"GET /auth/hmac?item=123&ts=1610000000&sig=<HMAC_SHA256(item|ts)>
// HMAC Validation Snippet
string payload = $"{item}|{ts}";
byte[] computed = CryptoUtils.ComputeHMAC(secretKey, payload);
if (!CryptoUtils.FixedTimeEquals(sigBytes, computed))
return Unauthorized();| Threat | STRIDE | NIST SSDF | OWASP SAMM | Compliance Example |
|---|---|---|---|---|
| Open Redirect | Tampering | RV.1, RV.2 | Design | ISO 27001 A.14: Secure System Dev |
| Basic Auth Leak | Info Disc | PW.3 | Implementation | PCI-DSS 8.3.1β6: Strong Auth |
| HMAC Bypass | Spoofing | PW.4, RV.4 | Verification | GDPR Art 32: Integrity & Confidentiality |
| CSRF (Form-Login) | Elevation | RV.3 | Operations | NIST 800-53 AC-4: Session Integrity |
Legend:
β’ PW β Password & Auth
β’ RV β Runtime Validation
Execute bash tests.sh to run all scenarios:
# 1) Open Redirect Attack
curl -i "http://localhost:5000/redirect?to=https://evil.com"
# 2) Insecure Basic-Auth Attempt
curl -v -u admin:password http://localhost:5000/secure/basic
# 3) Base64 Tampering
curl "http://localhost:5000/cart/add?item=999&sig=$(echo -n '999' | base64)"
# 4) HMAC Tampering
curl "http://localhost:5000/auth/hmac?item=123&ts=0&sig=invalid"βΆοΈ SAML/OIDC Integration: Simulate SSO broker & validate SAML assertionsβΆοΈ POST Form Support: HMAC auth via form POST payloadsβΆοΈ CI/CD Security Gates: Integrate checks in GitHub Actions or Azure PipelinesβΆοΈ Automated Threat Diagrams: Export STRIDE via OWASP Threat Dragon