Slide 1

Slide 1 text

Oops! I Committed My Password to GitHub! Miguel Grinberg

Slide 2

Slide 2 text

About Me ● Flask Web Development ● The Flask Mega-Tutorial ● The Flask Webcast ● Software Dev @ Rackspace ● APIs, Microservices, Security ● blog.miguelgrinberg.com ● github.com/miguelgrinberg ● @miguelgrinberg

Slide 3

Slide 3 text

Did you ever commit a password to source control? “Yeah, but it was by accident” “Yeah, but it’s fine because...”

Slide 4

Slide 4 text

How (not) to fix a password leak accident Make a new commit with the password removed Rebase the commit

Slide 5

Slide 5 text

How to fix a compromised password for real REVOKE IT!

Slide 6

Slide 6 text

Preventing Password Leaks in Code password = ‘HeyDontLookAtMyPassword!’ secret_key = ‘fhgj5khl7D56Hj89’ database_url = ‘mysql://user:password@server/db’ password = ‘HeyDontLookAtMyPassword!’ password = os.environ[‘PASSWORD’] secret_key = ‘fhgj5khl7D5GHj89’ secret_key = os.environ.get(‘SECRET_KEY’) database_url = ‘mysql://user:password@server/db’ database_url = os.environ.get(‘DATABASE_URL’, ‘sqlite:///’)

Slide 7

Slide 7 text

Adding secrets to the environment .profile, .bashrc or other user config files .env file for your project (add it to .gitignore) Do not type passwords in your shell!

Slide 8

Slide 8 text

Demonstration

Slide 9

Slide 9 text

If the environment is not enough Vault (Hashicorp) Parameter Store (AWS) Secret object (Kubernetes) Ansible Vault

Slide 10

Slide 10 text

DO NOT write passwords or tokens in your code DO import secrets from the environment or a secrets store DO revoke any secrets that might have been compromised DO NOT use services that don’t offer easy revocation DO NOT use the same password for more than one service DO NOT use the same credentials for all users DO’s and DON’Ts

Slide 11

Slide 11 text

Thank You! @miguelgrinberg