SlideShare a Scribd company logo
Emily Gladstone Cole @UnixGeekEm
My AWS Access Key
Nightmares… and Solutions
Emily Gladstone Cole @UnixGeekEm
Agenda
1. Introduction
2. Nightmare #1: Access Keys in Source Code
3. Nightmare #2: Old Access Keys
4. Nightmare #3: Keys on Disk
5. Access Key Best Practices
Emily Gladstone Cole @UnixGeekEm
Who is this Emily Person Anyway?
PAST
CURRENT
FUN FACTS
● UNIX SysAdmin/Operations background
● Experience in Security Incident Response, Security Research,
Security Engineering
● Senior Security Engineer at
● Mentor for SANS’ Women’s CyberTalent Immersion Academy
● My favorite computer game is Nethack
● None of the cats you will see here today are mine
Emily Gladstone Cole @UnixGeekEm
Disclaimers
I am not affiliated with Amazon or AWS.
I’m not being paid to give this talk.
I’m sharing what I have learned. There
are many others who know more about
AWS and Access Keys than I do. Some of
them are cited in the references.
Emily Gladstone Cole @UnixGeekEm
What is an AWS Access Key?
Access Key ID:
● Always starts with AKIA…
● Is the equivalent to your username
Secret Access Key:
● Secret really means secret
● Treat this key like a password
Emily Gladstone Cole @UnixGeekEm
When your Access Key is
compromised, an attacker
can do anything you can.
Emily Gladstone Cole @UnixGeekEm
For those of
you who
already knew
all this, this
slide is for
you.
On to the
good stuff!
Emily Gladstone Cole @UnixGeekEm
Nightmare #1
Access Keys in Source Code
Emily Gladstone Cole @UnixGeekEm
Access Keys in Source Code
When the repo is public, this means almost instant
compromise of the keys.
Remember: attackers can do anything you can, using
your Access Key and Secret Key.
● View and copy customer data
● Bitcoin Mining
Emily Gladstone Cole @UnixGeekEm
Oh shhgit
Emily Gladstone Cole @UnixGeekEm
How can YOU find Access Keys in Source Code?
We can detect them with source code scanners!
● truffleHog
● git-secrets
● detect-secrets (can be run as a pre-commit hook)!
Emily Gladstone Cole @UnixGeekEm
What if I find an Access Key
● Rotate the key so it’s no longer valid
● Delete the commit that contained the Access Key so it’s not
sitting in the commit history
● Talk with your Dev team about storing keys differently
Emily Gladstone Cole @UnixGeekEm
DIY Honeypots: Canary Tokens
Canary Tokens are one implementation of a honeytoken.
● Can be in the form of a document, a key, a QR code, a DNS record…
● Alerts can be generated when the token is accessed, either to an email
address or a webhook
● You can know if someone is in your data
● Your Dev team will probably find this idea fun
Emily Gladstone Cole @UnixGeekEm
Nightmare #2
Old Access Keys
Emily Gladstone Cole @UnixGeekEm
Access Keys get old
The longer an Access Key is around, the greater the chance it can be found
somewhere it shouldn’t.
Emily Gladstone Cole @UnixGeekEm
The longer Access Keys are
around, the higher the
chances something may
happen to them accidentally.
Emily Gladstone Cole @UnixGeekEm
Solution: Rotate your Access Keys
You can rotate your Access Keys manually, and it’s fairly straightforward.
There are tools to help you rotate your Access Keys automatically, like
aws-rotate-iam-keys which works well for individuals, but for application
users, it’s not that simple.
Emily Gladstone Cole @UnixGeekEm
Nightmare #3
Access Keys On Disk
Emily Gladstone Cole @UnixGeekEm
Bars and Cars
Emily Gladstone Cole @UnixGeekEm
Other ways to expose keys on disk
● Store them in environment variables
● Write them to log files
● Expose them through the Amazon Meta Data service v1 (Capital One)
Emily Gladstone Cole @UnixGeekEm
Hide Access Keys: aws-vault and vault
Using a vault tool will allow you to store your keys in a keystore, and interact
with the pointers, not the actual keys.
I don’t recommend storing shared AWS Access Keys in password managers.
Emily Gladstone Cole @UnixGeekEm
Don’t use permanent Access Keys at all
● Security Token Service can generate temporary credentials
○ Credentials inherently expire
● Roles use STS to delegate permissions
○ Roles can be created with Policies assigned
○ Can be used to grant access to a user in another account (cross-account)
○ Can be used by instances or applications
Emily Gladstone Cole @UnixGeekEm
Access Key Best
Practices
Emily Gladstone Cole @UnixGeekEm
If you were napping during the
first part of my talk, here’s a
quick meme to catch you up.
Emily Gladstone Cole @UnixGeekEm
Squad Goals: Access Keys are accessible only when needed
● Don’t have permanently-valid Keys sitting around in your source code
● Don’t have them sitting on disk
● Don’t have them loaded in environment variables
● Do have Keys that are only valid for a short amount of time
● Do have unique Keys for each user and application
● Only request a Key when you are about to use it
Emily Gladstone Cole @UnixGeekEm
Coming Soon: SSO and AWS
Can be used with Okta, Onelogin, Ping...
Here are some Okta-based integrations:
● okta-aws
● okta-awscli
● okta-aws-cli-assume-role
● AWS recently came out with an Okta integration as well!
Tying AWS into our SSO provider is our next step. We haven’t built that yet at
my company, but we’re working on it right now.
Emily Gladstone Cole @UnixGeekEm
References
1. truffleHog: https://github.com/dxa4481/truffleHog
2. git-secrets: https://github.com/awslabs/git-secrets
3. detect-secrets: https://github.com/Yelp/detect-secrets
4. shhgit: https://shhgit.darkport.co.uk/
5. Canary Tokens: https://canarytokens.org/generate
6. Cuckoo’s Egg: https://en.wikipedia.org/wiki/The_Cuckoo%27s_Egg
7. aws-rotate-iam-keys: https://github.com/rhyeal/aws-rotate-iam-keys
8. aws-vault: https://github.com/99designs/aws-vault
9. https://github.com/RiotGames/key-conjurer
10. Vault: https://www.vaultproject.io/docs
11. Amazon Meta Data Service v2:
https://blog.appsecco.com/getting-started-with-version-2-of-aws-ec2-instance-metadata-service-imdsv
2-2ad03a1f3650
12. https://static.sched.com/hosted_files/bsidessf2020/83/How%20to%20Kill%20an%20Access%20Key%20
rev%2020200223.pdf
Emily Gladstone Cole @UnixGeekEm
Thank you!

More Related Content

Similar to My AWS Access Key Nightmares... and Solutions

Forward Secrecy
Forward SecrecyForward Secrecy
Forward Secrecy
Kevin OBrien
 
Hunting for the secrets in a cloud forest
Hunting for the secrets in a cloud forestHunting for the secrets in a cloud forest
Hunting for the secrets in a cloud forest
SecuRing
 
PBU-Intro_to_PGP
PBU-Intro_to_PGPPBU-Intro_to_PGP
PBU-Intro_to_PGP
auremoser
 
amer-network-sihubconferances-security.ppt
amer-network-sihubconferances-security.pptamer-network-sihubconferances-security.ppt
amer-network-sihubconferances-security.ppt
navidkamrava
 
Cybersecurity Awareness Training Presentation v1.3
Cybersecurity Awareness Training Presentation v1.3Cybersecurity Awareness Training Presentation v1.3
Cybersecurity Awareness Training Presentation v1.3
DallasHaselhorst
 
BTC2019 - The Key Creation Ceremony
BTC2019 - The Key Creation CeremonyBTC2019 - The Key Creation Ceremony
BTC2019 - The Key Creation Ceremony
Joshua McDougall
 
11 Commandments of Cyber Security for the Home
11 Commandments of Cyber Security for the Home11 Commandments of Cyber Security for the Home
11 Commandments of Cyber Security for the Home
zaimorkai
 
ContainerDays Boston 2016: "Hiding in Plain Sight: Managing Secrets in a Cont...
ContainerDays Boston 2016: "Hiding in Plain Sight: Managing Secrets in a Cont...ContainerDays Boston 2016: "Hiding in Plain Sight: Managing Secrets in a Cont...
ContainerDays Boston 2016: "Hiding in Plain Sight: Managing Secrets in a Cont...
DynamicInfraDays
 
Securing password
Securing passwordSecuring password
Securing password
splendorcollege
 
Bringing Down the House - How One Python Script Ruled Over AntiVirus
Bringing Down the House - How One Python Script Ruled Over AntiVirusBringing Down the House - How One Python Script Ruled Over AntiVirus
Bringing Down the House - How One Python Script Ruled Over AntiVirus
CTruncer
 
Wordlist Generation and Wifi Cracking
Wordlist Generation and Wifi CrackingWordlist Generation and Wifi Cracking
Wordlist Generation and Wifi Cracking
Shakar Bhattarai
 
Why we are getting better at catching nation-state sponsored malware
Why we are getting better at catching nation-state sponsored malwareWhy we are getting better at catching nation-state sponsored malware
Why we are getting better at catching nation-state sponsored malware
Positive Hack Days
 
Password Cracking
Password CrackingPassword Cracking
Password Cracking
Hajer alriyami
 
Public Vs. Private Keys
Public Vs. Private KeysPublic Vs. Private Keys
Public Vs. Private Keys
101 Blockchains
 
Password Managers - Lastpass
Password Managers - LastpassPassword Managers - Lastpass
Password Managers - Lastpass
Bertold Kolics
 
How to Create (use use) Strong & Unique Passwords
How to Create (use use) Strong & Unique PasswordsHow to Create (use use) Strong & Unique Passwords
How to Create (use use) Strong & Unique Passwords
ConnectSafely
 
Security in the face of adversity
Security in the face of adversitySecurity in the face of adversity
Security in the face of adversity
David Tibbs
 
Privacy is a UX problem (David Dahl)
Privacy is a UX problem (David Dahl)Privacy is a UX problem (David Dahl)
Privacy is a UX problem (David Dahl)
Future Insights
 
Encryption basics
Encryption basicsEncryption basics
Encryption basics
Kevin OBrien
 
One Time Pad Journal
One Time Pad JournalOne Time Pad Journal
One Time Pad Journal
Amirul Wiramuda
 

Similar to My AWS Access Key Nightmares... and Solutions (20)

Forward Secrecy
Forward SecrecyForward Secrecy
Forward Secrecy
 
Hunting for the secrets in a cloud forest
Hunting for the secrets in a cloud forestHunting for the secrets in a cloud forest
Hunting for the secrets in a cloud forest
 
PBU-Intro_to_PGP
PBU-Intro_to_PGPPBU-Intro_to_PGP
PBU-Intro_to_PGP
 
amer-network-sihubconferances-security.ppt
amer-network-sihubconferances-security.pptamer-network-sihubconferances-security.ppt
amer-network-sihubconferances-security.ppt
 
Cybersecurity Awareness Training Presentation v1.3
Cybersecurity Awareness Training Presentation v1.3Cybersecurity Awareness Training Presentation v1.3
Cybersecurity Awareness Training Presentation v1.3
 
BTC2019 - The Key Creation Ceremony
BTC2019 - The Key Creation CeremonyBTC2019 - The Key Creation Ceremony
BTC2019 - The Key Creation Ceremony
 
11 Commandments of Cyber Security for the Home
11 Commandments of Cyber Security for the Home11 Commandments of Cyber Security for the Home
11 Commandments of Cyber Security for the Home
 
ContainerDays Boston 2016: "Hiding in Plain Sight: Managing Secrets in a Cont...
ContainerDays Boston 2016: "Hiding in Plain Sight: Managing Secrets in a Cont...ContainerDays Boston 2016: "Hiding in Plain Sight: Managing Secrets in a Cont...
ContainerDays Boston 2016: "Hiding in Plain Sight: Managing Secrets in a Cont...
 
Securing password
Securing passwordSecuring password
Securing password
 
Bringing Down the House - How One Python Script Ruled Over AntiVirus
Bringing Down the House - How One Python Script Ruled Over AntiVirusBringing Down the House - How One Python Script Ruled Over AntiVirus
Bringing Down the House - How One Python Script Ruled Over AntiVirus
 
Wordlist Generation and Wifi Cracking
Wordlist Generation and Wifi CrackingWordlist Generation and Wifi Cracking
Wordlist Generation and Wifi Cracking
 
Why we are getting better at catching nation-state sponsored malware
Why we are getting better at catching nation-state sponsored malwareWhy we are getting better at catching nation-state sponsored malware
Why we are getting better at catching nation-state sponsored malware
 
Password Cracking
Password CrackingPassword Cracking
Password Cracking
 
Public Vs. Private Keys
Public Vs. Private KeysPublic Vs. Private Keys
Public Vs. Private Keys
 
Password Managers - Lastpass
Password Managers - LastpassPassword Managers - Lastpass
Password Managers - Lastpass
 
How to Create (use use) Strong & Unique Passwords
How to Create (use use) Strong & Unique PasswordsHow to Create (use use) Strong & Unique Passwords
How to Create (use use) Strong & Unique Passwords
 
Security in the face of adversity
Security in the face of adversitySecurity in the face of adversity
Security in the face of adversity
 
Privacy is a UX problem (David Dahl)
Privacy is a UX problem (David Dahl)Privacy is a UX problem (David Dahl)
Privacy is a UX problem (David Dahl)
 
Encryption basics
Encryption basicsEncryption basics
Encryption basics
 
One Time Pad Journal
One Time Pad JournalOne Time Pad Journal
One Time Pad Journal
 

Recently uploaded

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 

Recently uploaded (20)

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 

My AWS Access Key Nightmares... and Solutions

  • 1. Emily Gladstone Cole @UnixGeekEm My AWS Access Key Nightmares… and Solutions
  • 2. Emily Gladstone Cole @UnixGeekEm Agenda 1. Introduction 2. Nightmare #1: Access Keys in Source Code 3. Nightmare #2: Old Access Keys 4. Nightmare #3: Keys on Disk 5. Access Key Best Practices
  • 3. Emily Gladstone Cole @UnixGeekEm Who is this Emily Person Anyway? PAST CURRENT FUN FACTS ● UNIX SysAdmin/Operations background ● Experience in Security Incident Response, Security Research, Security Engineering ● Senior Security Engineer at ● Mentor for SANS’ Women’s CyberTalent Immersion Academy ● My favorite computer game is Nethack ● None of the cats you will see here today are mine
  • 4. Emily Gladstone Cole @UnixGeekEm Disclaimers I am not affiliated with Amazon or AWS. I’m not being paid to give this talk. I’m sharing what I have learned. There are many others who know more about AWS and Access Keys than I do. Some of them are cited in the references.
  • 5. Emily Gladstone Cole @UnixGeekEm What is an AWS Access Key? Access Key ID: ● Always starts with AKIA… ● Is the equivalent to your username Secret Access Key: ● Secret really means secret ● Treat this key like a password
  • 6. Emily Gladstone Cole @UnixGeekEm When your Access Key is compromised, an attacker can do anything you can.
  • 7. Emily Gladstone Cole @UnixGeekEm For those of you who already knew all this, this slide is for you. On to the good stuff!
  • 8. Emily Gladstone Cole @UnixGeekEm Nightmare #1 Access Keys in Source Code
  • 9. Emily Gladstone Cole @UnixGeekEm Access Keys in Source Code When the repo is public, this means almost instant compromise of the keys. Remember: attackers can do anything you can, using your Access Key and Secret Key. ● View and copy customer data ● Bitcoin Mining
  • 10. Emily Gladstone Cole @UnixGeekEm Oh shhgit
  • 11. Emily Gladstone Cole @UnixGeekEm How can YOU find Access Keys in Source Code? We can detect them with source code scanners! ● truffleHog ● git-secrets ● detect-secrets (can be run as a pre-commit hook)!
  • 12. Emily Gladstone Cole @UnixGeekEm What if I find an Access Key ● Rotate the key so it’s no longer valid ● Delete the commit that contained the Access Key so it’s not sitting in the commit history ● Talk with your Dev team about storing keys differently
  • 13. Emily Gladstone Cole @UnixGeekEm DIY Honeypots: Canary Tokens Canary Tokens are one implementation of a honeytoken. ● Can be in the form of a document, a key, a QR code, a DNS record… ● Alerts can be generated when the token is accessed, either to an email address or a webhook ● You can know if someone is in your data ● Your Dev team will probably find this idea fun
  • 14. Emily Gladstone Cole @UnixGeekEm Nightmare #2 Old Access Keys
  • 15. Emily Gladstone Cole @UnixGeekEm Access Keys get old The longer an Access Key is around, the greater the chance it can be found somewhere it shouldn’t.
  • 16. Emily Gladstone Cole @UnixGeekEm The longer Access Keys are around, the higher the chances something may happen to them accidentally.
  • 17. Emily Gladstone Cole @UnixGeekEm Solution: Rotate your Access Keys You can rotate your Access Keys manually, and it’s fairly straightforward. There are tools to help you rotate your Access Keys automatically, like aws-rotate-iam-keys which works well for individuals, but for application users, it’s not that simple.
  • 18. Emily Gladstone Cole @UnixGeekEm Nightmare #3 Access Keys On Disk
  • 19. Emily Gladstone Cole @UnixGeekEm Bars and Cars
  • 20. Emily Gladstone Cole @UnixGeekEm Other ways to expose keys on disk ● Store them in environment variables ● Write them to log files ● Expose them through the Amazon Meta Data service v1 (Capital One)
  • 21. Emily Gladstone Cole @UnixGeekEm Hide Access Keys: aws-vault and vault Using a vault tool will allow you to store your keys in a keystore, and interact with the pointers, not the actual keys. I don’t recommend storing shared AWS Access Keys in password managers.
  • 22. Emily Gladstone Cole @UnixGeekEm Don’t use permanent Access Keys at all ● Security Token Service can generate temporary credentials ○ Credentials inherently expire ● Roles use STS to delegate permissions ○ Roles can be created with Policies assigned ○ Can be used to grant access to a user in another account (cross-account) ○ Can be used by instances or applications
  • 23. Emily Gladstone Cole @UnixGeekEm Access Key Best Practices
  • 24. Emily Gladstone Cole @UnixGeekEm If you were napping during the first part of my talk, here’s a quick meme to catch you up.
  • 25. Emily Gladstone Cole @UnixGeekEm Squad Goals: Access Keys are accessible only when needed ● Don’t have permanently-valid Keys sitting around in your source code ● Don’t have them sitting on disk ● Don’t have them loaded in environment variables ● Do have Keys that are only valid for a short amount of time ● Do have unique Keys for each user and application ● Only request a Key when you are about to use it
  • 26. Emily Gladstone Cole @UnixGeekEm Coming Soon: SSO and AWS Can be used with Okta, Onelogin, Ping... Here are some Okta-based integrations: ● okta-aws ● okta-awscli ● okta-aws-cli-assume-role ● AWS recently came out with an Okta integration as well! Tying AWS into our SSO provider is our next step. We haven’t built that yet at my company, but we’re working on it right now.
  • 27. Emily Gladstone Cole @UnixGeekEm References 1. truffleHog: https://github.com/dxa4481/truffleHog 2. git-secrets: https://github.com/awslabs/git-secrets 3. detect-secrets: https://github.com/Yelp/detect-secrets 4. shhgit: https://shhgit.darkport.co.uk/ 5. Canary Tokens: https://canarytokens.org/generate 6. Cuckoo’s Egg: https://en.wikipedia.org/wiki/The_Cuckoo%27s_Egg 7. aws-rotate-iam-keys: https://github.com/rhyeal/aws-rotate-iam-keys 8. aws-vault: https://github.com/99designs/aws-vault 9. https://github.com/RiotGames/key-conjurer 10. Vault: https://www.vaultproject.io/docs 11. Amazon Meta Data Service v2: https://blog.appsecco.com/getting-started-with-version-2-of-aws-ec2-instance-metadata-service-imdsv 2-2ad03a1f3650 12. https://static.sched.com/hosted_files/bsidessf2020/83/How%20to%20Kill%20an%20Access%20Key%20 rev%2020200223.pdf
  • 28. Emily Gladstone Cole @UnixGeekEm Thank you!