T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/before.py:83- Finding
Unnecessary Retrieval of Contact Personally Identifiable Information
- Content
View full analysis
Vulnerability Details
File Location:
scripts/before.py:83-111andscripts/after.py:92-120
Vulnerability Type: Excessive CRM data access violating least-privilege principles
Risk Level: MediumComplete Code Snippet
scripts/before.py:83-111:python while sampled < SAMPLE_SIZE: payload = { "filterGroups": [{"filters": [ {"propertyName": "company", "operator": "NOT_HAS_PROPERTY"}, ]}], "properties": ["email", "firstname", "lastname", "company"], "limit": 100, } if after: payload["after"] = after resp = requests.post(SEARCH_URL, headers=HEADERS, json=payload) if resp.status_code != 200: print(f" Search error {resp.status_code} — stopping sample.") break data = resp.json() results = data.get("results", []) if not results: break for contact in results: cid = contact["id"] assoc_resp = requests.get( f"{BASE}/crm/v4/objects/contacts/{cid}/associations/companies", headers=HEADERS, )scripts/after.py:92-120contains the equivalent behavior:python while sampled < SAMPLE_SIZE: payload = { "filterGroups": [{"filters": [ {"propertyName": "company", "operator": "NOT_HAS_PROPERTY"}, ]}], "properties": ["email", "firstname", "lastname", "company"], "limit": 100, } if after: payload["after"] = after resp = requests.post(SEARCH_URL, headers=HEADERS, json=payload) if resp.status_code != 200: break data = resp.json() results = data.get("results", []) if not results: break for contact in results: cid = contact["id"] assoc_resp = requests.get( f"{BASE}/crm/v4/objects/contacts/{cid}/associations/companies", headers=HEADERS, ...[truncated 2088 chars]- Remediation
View remediation
Remediation Suggestions
-
Remove the unnecessary
propertiesentry if HubSpot returns object IDs without an explicit property selection:python payload = { "filterGroups": [{"filters": [ {"propertyName": "company", "operator": "NOT_HAS_PROPERTY"}, ]}], "limit": 100, } -
If the API requires an explicit property selection, request only a non-sensitive field strictly necessary for pagination or object identification.
-
Apply the same correction to both
scripts/before.pyandscripts/after.py. -
Avoid enabling HTTP body logging while processing CRM responses.
-
Use a HubSpot private-app token restricted to the minimum read-only CRM scopes needed by these audit scripts.
-
Keep generated reports aggregate-only, as the current CSV output already does.
-
