Skip to content

fix: block referral farming via disposable accounts (Closes #636)#638

Merged
indresh404 merged 2 commits into
indresh404:mainfrom
Priyanka0205-CSE:fix/referral-self-farming-636
Jul 22, 2026
Merged

fix: block referral farming via disposable accounts (Closes #636)#638
indresh404 merged 2 commits into
indresh404:mainfrom
Priyanka0205-CSE:fix/referral-self-farming-636

Conversation

@Priyanka0205-CSE

Copy link
Copy Markdown
Contributor

What this fixes

Closes #636

The referral system credited +100 points the moment any new user signed up with a referral code, with no check on whether the new account was a real, distinct person. This let a user create disposable GitHub accounts and farm their own referral link indefinitely.

Changes

  • firestore.rules: added refereeIsLegitimate() — requires the referee's own account to be ≥30 days old (measured from their GitHub account creation date) and have at least 1 public repo or follower, before any referral point credit is allowed.
  • AuthContext.jsx: now captures githubCreatedAt, githubPublicRepos, githubFollowers, and a derived githubAccountAgeAtSignupDays at signup, so the rule above has something to check.
  • Onboarding.jsx: split the referral crediting out of the account-creation transaction into a separate step that runs after the new user's own doc exists — this is required because Firestore security rules can't get() a document written earlier in the same transaction.

Testing

I don't have deploy access to the project's live Firebase instance, so I wasn't able to test this against the real database — the logic has been reasoned through carefully but hasn't been runtime-verified. Would appreciate a maintainer test before merge.

Note

A more robust fix (server-side validation via a Cloud Function, potentially with signup-IP correlation) was considered but the project doesn't currently have any Cloud Functions or admin backend infrastructure set up, so this PR uses a rules-only approach that needed no new infrastructure.

@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ranker-hub Ready Ready Preview, Comment Jul 18, 2026 6:05pm

@github-actions github-actions Bot added backend Backend/Firebase related changes bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request frontend Frontend related changes (HTML/CSS/JS/React) nsoc NSoC NSoC'26 NSoC 2026 pending-review PR is pending review labels Jul 18, 2026
@indresh404
indresh404 merged commit 414d92b into indresh404:main Jul 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend/Firebase related changes bug Something isn't working documentation Improvements or additions to documentation ECSoC26-L2 ECSoC26 enhancement New feature or request frontend Frontend related changes (HTML/CSS/JS/React) nsoc NSoC NSoC'26 NSoC 2026 pending-review PR is pending review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Security]: Referral rules only block reused UIDs, not self-referral via disposable accounts

2 participants