Toutes les vulnérabilités
HIGHAppSec

APPSEC-GITHUB-MASSASSIGN-2012

Web app · GitHub (Ruby on Rails)

Résumé

On March 4, 2012 security researcher Egor Homakov demonstrated a mass-assignment flaw against GitHub itself, having days earlier been dismissed when he warned the Rails core team about the issue. GitHub's Rails controllers passed request parameters straight into ActiveRecord models via update_attributes with no attribute allowlist, so any extra form field was bound to the model. By adding an unexposed public_key user_id field set to 4223 (the rails organization's user id) while uploading his own SSH key, Homakov reassigned ownership of his key to the rails/rails organization, giving himself commit access, and pushed a proof-of-concept commit. This is a textbook mass-assignment / over-posting vulnerability where the model bound a sensitive attribute the form never rendered. GitHub briefly suspended his account, then reinstated it after confirming no malicious intent, and tightened mass-assignment protection across the platform.

Comment l’éviter dans votre code

  • Bind only an explicit allowlist of fields to models (strong params / DTOs); never pass raw request bodies to model setters.
  • Treat ownership and foreign-key attributes (user_id, owner_id, role) as server-set only, never client-assignable.
  • Default to deny: whitelist permitted attributes per endpoint instead of blacklisting dangerous ones.
  • Add tests asserting that protected attributes cannot be set via crafted request params.
  • Review every create/update path for over-posting when adding new model attributes.

Références

Vulnérabilités liées

Tout AppSec →