Private Account/Friend Request Flow
Why it matters
When a user marks their profile private, they are expressing a consent boundary — covered under GDPR Art. 25 and CCPA §1798.120. An instant-follow model that ignores the private flag grants content access without approval, defeating the user's explicit privacy setting. Under CWE-284, this is a failed authorization check: the platform makes the access control decision on behalf of the user rather than routing it through the user's own approval queue. The fix requires a FollowRequest table to hold pending state across the approval workflow.
Severity rationale
Low because the gap only surfaces when private accounts exist and is not a data exfiltration vector, but it directly violates the user's stated privacy preference.
Remediation
Add a FollowRequest model with a status enum to your Prisma schema, then branch your follow logic on the target account's is_private flag before deciding whether to create an instant follow or a pending request.
// lib/follow.ts
export async function requestFollow(followerId: string, followedId: string) {
const target = await db.user.findUniqueOrThrow({ where: { id: followedId } })
if (!target.is_private) {
return db.follow.create({ data: { followerId, followedId } })
}
return db.followRequest.create({
data: { followerId, followedId, status: 'pending' }
})
}
export async function approveFollowRequest(requestId: string, approverId: string) {
const req = await db.followRequest.findUniqueOrThrow({ where: { id: requestId } })
if (req.followedId !== approverId) throw new Error('Unauthorized')
await db.$transaction([
db.follow.create({ data: { followerId: req.followerId, followedId: req.followedId } }),
db.followRequest.update({ where: { id: requestId }, data: { status: 'accepted' } })
])
}
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 Social Features & Engagement Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-284 — Improper Access Control
- gdpr · Art. 25 — Data Protection by Design and by Default
- ccpa · §1798.120 — Right to opt out of sale or sharing of personal information
Taxons
History
- 2026-04-18·v1.0.0·Initial import from community-social-engagement·automated