Profile visibility enforced at three or more tiers at API layer
Why it matters
Profile visibility enforced only on the frontend is not enforced at all — any API client that bypasses the UI gets full profile data regardless of the user's privacy setting. OWASP A01:2021 (Broken Access Control) is the top web application vulnerability for exactly this reason. GDPR Art. 25 (privacy by design) requires access restriction to be a default, not an afterthought. A two-tier public/private model also fails users who want followers-only visibility, forcing them to choose between full exposure and full lockdown.
Severity rationale
Medium because unauthorized profile data access requires a direct API call, but the exposure is complete — every field on the profile is returned — once the frontend enforcement is bypassed.
Remediation
Add at least three visibility tiers to the users table and enforce the check in every API handler that returns profile data. Never rely on frontend filtering. In your profile API route (e.g., src/app/api/users/[id]/route.ts):
async function getUserProfile(requesterId: string, targetUserId: string) {
const user = await db.user.findUnique({ where: { id: targetUserId } });
const canView = await checkProfileVisibility(requesterId, targetUserId, user.profile_visibility);
if (!canView) throw new ForbiddenError('Profile not accessible');
return sanitizeProfile(user, requesterId);
}
Schema addition:
ALTER TABLE users ADD COLUMN profile_visibility VARCHAR(20)
DEFAULT 'public'
CHECK (profile_visibility IN ('public', 'friends_only', 'followers_only', 'private'));
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Community Privacy & Controls Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-285 — Improper Authorization
- owasp:2021 · A01 — Broken Access Control
- gdpr · Art. 25 — Data protection by design and by default
- nist:rev5 · AC-3 — Access Enforcement
Taxons
History
- 2026-04-18·v1.0.0·Initial import from community-privacy-controls·automated