In my previous series, we tore down the defenses of a Bank, exposing critical flaws in a fintech application that could lead to financial ruin.
For this new series, I am moving on to an even more sensitive domain: Healthcare.
Medical data is some of the most valuable currency on the dark web, more permanent than a credit card number and strictly regulated by laws like HIPAA.
My target for this Penetration Test is Zero Health, a modern AI-driven healthcare management API. My goal is simple: treat this like a real-world black-box engagement, map the attack surface, find the cracks, and see just how much damage an attacker could do.
This first part documents the entire kill chain, from initial reconnaissance to total system compromise via SQL Injection, Privilege Escalation, and BOLA.
The reconnaissance phase was divided into two distinct stages: Passive Reconnaissance, which focused on information gathering without direct interaction with the backend logic, and Active Reconnaissance, which involved traffic interception and runtime behavioral analysis of the application.
The objective of this phase was to map the application's attack surface using publicly available information and documentation provided by the application.
Methodology:
Findings:
Through documentation review and static analysis, the following endpoints were identified:
POST /api/register (User registration)
POST /api/login (User authentication)
GET /api/docs/ (Swagger UI)
GET /api/debug/connection (Database connectivity check)
GET /api/debug/token (Token debugging)
POST /api/chatbot/chat (AI Assistant interface)
GET /api/admin/users (Administrative user management)
GET /api/reports/generate (Report generation)
The objective of this phase was to capture "hidden" or undocumented endpoints by intercepting the traffic between the frontend and the backend.
Methodology:
Findings:
This active interception revealed several critical endpoints that were not fully detailed in the initial documentation:
GET /api/lab-results/:id (Retrieves specific medical records - Critical Target)
GET /api/prescriptions (Lists patient prescriptions)
GET /api/messages (Retrieves private patient-doctor communications)
GET /api/doctors (Lists available medical staff)
GET /api/users/profile (Retrieves current user details)
POST /api/auth/forgot-password (Password recovery mechanism)
With the map in hand, I moved to exploitation.
Severity: High | OWASP: API1:2023
The first crack appeared in the Lab Results endpoint. In a secure app, User A should never see User B's medical records. I wanted to test if Zero Health enforced this.
- Using the credentials discovered in the GitHub repository's source code during the reconnaissance phase, I authenticated as a Doctor.
- Using this privileged doctor account, I generated legitimate medical data (Lab Results and Prescription) specifically for the Victim user to ensure a valid target existed in the database.
In Burp Suite:
The server returned a 200 OK status code and a full JSON body containing the lab results for a different patient. The application failed to validate if the authenticated user (Victim) was the owner of the requested record (ID 1).
HIPAA Violation Analysis:
This vulnerability constitutes a direct violation of the HIPAA Privacy Rule (45 CFR § 164.502), which requires covered entities to protect the privacy of Protected Health Information (PHI).
Risk Assessment:
CVSS v3.1 Score: 6.5 (Medium-High)
To effectively mitigate Broken Object Level Authorization (BOLA) vulnerabilities, the following security controls should be implemented at the architectural level:
Severity: Critical (9.8)
OWASP Mapping: API2:2023 - Broken Authentication / API5:2023 - Broken Function Level Authorization
Tools Used: xjwt.io (Decoder & Cracker), Burp Suite
Following the successful exploitation of the BOLA vulnerability, I investigated the authentication mechanism itself to understand how the application validates user identity. The application uses JSON Web Tokens (JWT) for stateless authentication.
Curious about the token's structure and strength, I used the valid JWT assigned to the victim account to analyze it with the online tool xjwt.io.
Decoding: The tool successfully decoded the token header and payload, revealing critical metadata:
Since HS256 relies on a shared secret, its security depends entirely on the complexity of that secret. I utilized the xjwt.io Cracker Tool, which performs a dictionary attack against the token's signature.
Armed with the valid signing secret, I performed a Vertical Privilege Escalation attack:
To confirm the privileges of the forged token, I returned to Burp Suite and replaced the original authorization header with the new "Doctor" token. I attempted to access privileged endpoints that were previously restricted:
Impact Analysis:
This vulnerability represents a total compromise of the application's security model.
CVSS v3.1 Score: 9.8 (Critical)
To secure the JWT implementation, the following steps must be taken immediately:
Severity: Critical (9.8)
OWASP Mapping: API8:2019 - Injection / A03:2021 - Injection
Endpoint Tested: POST /api/login
While assessing the authentication mechanisms, I identified that the login endpoint (/api/login) lacks proper input sanitization. The application appears to construct SQL queries by directly concatenating user input into the query string. This vulnerability, known as SQL Injection (SQLi), allows an attacker to manipulate the backend database query logic.
By injecting standard SQL comment syntax and boolean logic (OR 1=1), I forced the database to evaluate the password check as "True" for the first user in the users table, typically the Administrator.
I targeted the login API endpoint POST /api/login, which accepts JSON credentials (email and password).
I crafted a malicious JSON payload designed to alter the SQL query logic.
Theory: The injected payload likely transforms the backend query into something similar to:
SELECT * FROM users WHERE email = 'mel@test.com' OR '1'='1' --' AND password = '...'
The -- comments out the password verification, and '1'='1' ensures the condition is always true.
I sent the request via Postman.
The API responded with a 200 OK status code.
Impact Analysis:
This is a catastrophic vulnerability that compromises the entire application trust boundary.
CVSS v3.1 Score: 9.8 (Critical)
To permanently fix SQL Injection, the following coding practices must be enforced:
That’s it for Part 1! In this initial phase, I successfully mapped the entire application surface through active and passive reconnaissance, bypassed authentication via SQL Injection to gain administrator access, escalated privileges by cracking weak JWT secrets, and exposed sensitive patient data through Broken Object Level Authorization (BOLA).
See you in Part 2!