33.2 Hashing, Salts and Password Storage
A hash function turns any input into a fixed-length fingerprint. Good hashes are one-way, and a tiny change in input gives a completely different output (the "avalanche effect").
| Algorithm | Output | Status |
|---|---|---|
| MD5 | 128-bit | Broken – collisions are practical; never for security |
| SHA-1 | 160-bit | Broken for collisions; being retired |
| SHA-256 / SHA-3 | 256-bit | Safe for integrity and signatures |
| bcrypt, scrypt, Argon2, PBKDF2 | Variable | Designed for passwords – slow on purpose |
Uses: checking downloads (compare the published SHA-256 of the Kali ISO), file integrity (Wazuh FIM, Chapter 31), digital forensics (hash evidence before and after, Chapter 28), and password storage.
Passwords need special care. A plain fast hash like SHA-256 lets Hashcat try billions of guesses per second (Chapter 22). So we use:
- a salt – a random value added per user, so the same password gives different hashes and rainbow tables fail;
- a slow algorithm (bcrypt/Argon2) with a work factor, so each guess is expensive.
sha256sum kali-linux-installer-amd64.iso # compare with the value on kali.org
php -r 'echo password_hash("Pune123", PASSWORD_BCRYPT), PHP_EOL;' # different every run (salt)
openssl passwd -6 -salt Xy12 Pune123 # SHA-512 crypt, like /etc/shadow ($6$)
A HMAC (hash + secret key) proves both integrity and that the sender knew the key – used in API signatures and JWT tokens (HS256).
Ravindra Bagale's Tip
Students store passwords with md5($password) or sha256($password) and ask, "It's a hash, so it's safe, right?" No! A fast hash is easy to crack. In PHP always use password_hash() and password_verify() – you get salt and bcrypt automatically.
Ravindra Bagale's Tip – मराठी
Students md5($password) किंवा sha256($password) ने password save करतात आणि विचारतात "hash आहे ना, मग safe?" नाही! Fast hash crack करायला सोपा. PHP मध्ये नेहमी password_hash() आणि password_verify() वापरा – salt आणि bcrypt आपोआप येतात.
Ravindra Bagale's Tip – हिंदी
Students md5($password) या sha256($password) से password save करते हैं और पूछते हैं "hash है ना, तो safe?" नहीं! Fast hash crack करना आसान है. PHP में हमेशा password_hash() और password_verify() इस्तेमाल करो – salt और bcrypt अपने-आप मिलते हैं.
Lab
In your lab, create two users with the same password and compare their lines in /etc/shadow – note the different salts. Then use john (Chapter 22) on an MD5 hash and a bcrypt hash of the same weak password and compare how long each takes.
Extended teaching notes
Why this lesson matters
Cryptography fails when people invent it. Use standard libraries, modern algorithms (AES-GCM, TLS 1.2+, bcrypt/argon2) and protect keys in a KMS or secrets manager.
Where crypto shows up
[('Passwords', 'bcrypt/argon2/PBKDF2 via the framework hasher — never plain MD5/SHA1.'), ('TLS', "Terminate on ALB/nginx with ACM/Let's Encrypt; redirect HTTP to HTTPS."), ('JWT / API tokens', 'Short lifetime, rotate signing keys, store secrets outside Git.'), ('Disk / S3', 'Provider or customer-managed keys; least privilege on decrypt.')]
Mini case study
Suppose we are on a purple-team exercise for an Indian mid-size company (sample data). Red notes a technique from this lesson against a lab clone. Blue must show the control that stops it, the log that would have fired, and the ticket that hardens production. That is the standard this course trains you for.
Defender's worksheet (do this today)
- Write the lesson title, date and the exact lab target you are allowed to use.
- List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
- Run one safe check from the lesson on a lab system only. Paste the command and output.
- Write a two-sentence fix you would give a teammate.
- Name one related public advisory (CERT-In, CISA, NVD, or a vendor bulletin) with its date.
Indian workplace (sample data)
Suppose we are a junior analyst at Infosys, TCS, Wipro or a fintech SOC in Bengaluru/Pune. Turn this lesson into one checklist item with an owner, a due date and a place to store evidence (ticket + screenshot).
Global practice
Compare your notes with OWASP, CIS Benchmarks, NIST CSF/IR guidance or a cloud Well-Architected security question. Write five lines on what overlaps.
Everyday analogy
Explain the risk and the fix to a family member without jargon. If they can repeat the warning, you understand it well enough to teach juniors.
Key terms
- Control: a safeguard (patch, config, process, detection).
- Finding: a weakness backed by evidence.
- Remediation: the fix plus how you verified it.
- Scope: systems you have written permission to touch.
- Least privilege: only the access the task needs.
- Defence in depth: several layers so one failure does not end the story.
Common mistakes
- Skipping written permission "just for a quick scan".
- Practising on hostel, office or public targets without authorisation.
- Collecting tool output without writing the fix.
- Copying attack steps onto production to "verify". Defenders verify with versions, configs and patches.
- Publishing screenshots that contain secrets, cookies or internal hostnames.
Recap
- Evidence, fix, owner, date.
- Own lab only.
- Fix > spectacle.
Real incident: Todoist – an attacker reached production and downloaded old salted SHA-1 password hashes of early users (Nov 2026)
1. What happened
In this lesson you learnt that passwords must be stored with a slow password hash like bcrypt or Argon2, not a fast one like SHA-1. Why does this case matter? Because a real company still had old SHA-1 hashes for some users, and an attacker took them.
- Todoist is a popular to-do list and task app.
- Todoist says that between 22 and 23 November 2026 an attacker used a stolen credential for its version control system. With it, they changed automated workflows in three repositories and got more credentials. They could also read source code. Todoist found no changes to app code.
- One of those credentials let the attacker change how employees sign in to internal systems. They took over an employee's work account and reached Todoist's cloud infrastructure.
- On 23 November the attacker downloaded a file for some early users whose passwords were still stored with an older method: salted SHA-1. It had email addresses, password hashes and account creation dates. This was about 6% of users. Todoist saw no sign that the attacker signed in to those accounts.
- For much smaller groups, the attacker took Todoist API tokens and Slack integration tokens, searched some customer content for credentials, and read email details through connected Todoist for Outlook accounts.
- Those old hashes stayed because those users had not changed their password since Todoist stopped using SHA-1 over ten years ago. Todoist said it should have retired it sooner, and has now done so.
- Todoist blocked the attack paths, replaced exposed internal credentials and protected affected accounts. It has not found how the first credential was stolen; its leading theory is a compromised employee device, which is unconfirmed.
2. How the hack happened (public reporting only – high-level)
- The attacker had a stolen credential for Todoist's code platform.
- They changed automated workflows (CI jobs) in three repositories to collect more credentials.
- One of those credentials let them change employee sign-in settings, so they took over an employee's work account.
- From there they reached the cloud and production systems.
- They downloaded a file of old salted SHA-1 password hashes, plus some tokens.
- Why this hurts: SHA-1 is fast. Attackers can try many password guesses per second on a fast hash, offline, so weak or reused passwords are at risk.
3. How to stop it / defend (this lesson: hashing, salts and password storage)
Why: a salt stops one guess working on many users at once, but only a slow hash makes each guess expensive.
What a team can do:
- Use a slow password hash: Argon2, bcrypt or scrypt, with a good work factor.
- Upgrade old hashes. When a user signs in, check the old hash and save a new Argon2 or bcrypt hash at once.
- Set an end date for old methods. Users who never sign in again get a forced password reset, so no SHA-1 hash stays for years.
- Keep the password table hard to reach. Only the login service should read it, and big exports should raise an alert.
- Protect the path to production too: short-lived tokens for code and CI, and review for any change to workflows.
Example: a simple "old hash" count.
- Rule: every stored password uses Argon2 or bcrypt.
- Action: count how many user rows still use any other hash type (each hash usually shows its type at the start).
- Check: the number should be zero. If not, upgrade at next sign-in and set a reset date for the rest.
- What it means: if the database ever leaks, attackers get only slow, hard-to-guess hashes.
4. How to take care so it won't happen again (checklist)
- [ ] All passwords are stored with Argon2, bcrypt or scrypt.
- [ ] Old hashes are upgraded at sign-in, and old methods have an end date.
- [ ] Only the login service can read password hashes; large exports raise an alert.
- [ ] Code platform and CI tokens are short-lived, and workflow changes need review.
- [ ] As a user: use a unique password for every app, keep it in a password manager, and change it at once if a breach notice comes.
- [ ] Never keep API keys or recovery phrases in task notes or comments.
Source: Todoist, "Security incident in November 2026" (help centre notice), 25 November 2026; TechCrunch, "Todoist confirms 6% of customers’ details were stolen in data breach", 25 November 2026.
1. काय झालं
या lesson मध्ये आपण शिकलो की passwords नेहमी bcrypt किंवा Argon2 सारख्या slow password hash ने store करायचे, SHA-1 सारख्या fast hash ने नाही. ही घटना का महत्वाची आहे? कारण एका खऱ्या company कडे काही users चे जुने SHA-1 hashes अजून होते, आणि attacker ने ते नेले.
- Todoist हे एक popular to-do list आणि task app आहे.
- Todoist सांगतं की 22 आणि 23 नोव्हेंबर 2026 दरम्यान एका attacker ने त्यांच्या version control system चं चोरलेलं credential वापरलं. त्याने तीन repositories मधले automated workflows बदलले आणि अजून credentials मिळवले. तो source code पण वाचू शकत होता. App code मध्ये काही बदल झालेला Todoist ला दिसला नाही.
- त्यातल्या एका credential ने attacker ला employees internal systems मध्ये कसे sign in करतात ते बदलता आलं. त्याने एका employee चं work account ताब्यात घेतलं आणि Todoist च्या cloud infrastructure पर्यंत पोहोचला.
- 23 नोव्हेंबर ला attacker ने काही जुन्या users ची file download केली, ज्यांचे passwords अजून जुन्या पद्धतीने, म्हणजे salted SHA-1 ने store होते. त्यात email addresses, password hashes आणि account कधी बनलं ती date होती. हे साधारण 6% users होते. Attacker ने त्या accounts मध्ये sign in केल्याचं Todoist ला दिसलं नाही.
- खूप छोट्या groups साठी attacker ने Todoist API tokens आणि Slack integration tokens घेतले, काही customer content मध्ये credentials शोधले, आणि connected Todoist for Outlook accounts मधून email details वाचले.
- हे जुने hashes राहिले कारण त्या users नी Todoist ने SHA-1 वापरणं बंद केल्यापासून, म्हणजे दहा वर्षांपेक्षा जास्त काळ, password बदलला नव्हता. Todoist म्हणालं की हे आधीच बंद करायला हवं होतं, आणि आता केलं आहे.
- Todoist ने attack चे रस्ते block केले, expose झालेले internal credentials बदलले आणि affected accounts protect केले. पहिलं credential कसं चोरलं गेलं हे अजून कळलेलं नाही; त्यांचा मुख्य अंदाज आहे की एका employee चा device compromise झाला असेल, पण हे confirm नाही.
2. Hack कसा झाला (फक्त public reporting – high-level)
- Attacker कडे Todoist च्या code platform चं चोरलेलं credential होतं.
- त्याने तीन repositories मधले automated workflows (CI jobs) बदलले, म्हणजे अजून credentials गोळा करता येतील.
- त्यातल्या एका credential ने employee sign-in settings बदलता आल्या, म्हणून त्याने एका employee चं work account ताब्यात घेतलं.
- तिथून तो cloud आणि production systems पर्यंत पोहोचला.
- त्याने जुन्या salted SHA-1 password hashes ची file आणि काही tokens download केले.
- हे का धोकादायक: SHA-1 fast आहे. Fast hash वर attackers offline एका second मध्ये खूप password guesses try करू शकतात, म्हणून weak किंवा reuse केलेले passwords धोक्यात येतात.
3. हे कसं थांबवायचं / defend कसं करायचं (हा lesson: hashing, salts आणि password storage)
का: Salt मुळे एक guess एकाच वेळी अनेक users वर चालत नाही, पण फक्त slow hash च प्रत्येक guess महाग करतो.
Team काय करू शकते:
- Slow password hash वापरा: Argon2, bcrypt किंवा scrypt, चांगल्या work factor सोबत.
- जुने hashes upgrade करा. User sign in करतो तेव्हा जुना hash check करा आणि लगेच नवीन Argon2 किंवा bcrypt hash save करा.
- जुन्या पद्धतींना end date द्या. जे users परत sign in करत नाहीत त्यांना forced password reset द्या, म्हणजे कोणताही SHA-1 hash वर्षानुवर्षे राहणार नाही.
- Password table पर्यंत पोहोचणं कठीण ठेवा. फक्त login service ने ते वाचावं, आणि मोठं export झालं तर alert यावा.
- Production पर्यंतचा रस्ता पण protect करा: code आणि CI साठी short-lived tokens, आणि workflows मधल्या प्रत्येक change ला review.
Example: "जुना hash" मोजायचा सोपा drill.
- Rule: store केलेला प्रत्येक password Argon2 किंवा bcrypt वापरतो.
- Action: अजून दुसरा कोणताही hash type वापरणारे किती user records आहेत ते count करा (प्रत्येक hash च्या सुरुवातीला साधारण त्याचा type दिसतो).
- Check: हा आकडा zero असायला हवा. नसेल तर पुढच्या sign-in ला upgrade करा आणि बाकीच्यांसाठी reset date ठरवा.
- याचा अर्थ: database कधी leak झाला तरी attackers ना फक्त slow, guess करायला कठीण hashes मिळतात.
4. परत असं होऊ नये म्हणून काळजी (checklist)
- [ ] सगळे passwords Argon2, bcrypt किंवा scrypt ने store होतात.
- [ ] जुने hashes sign-in वेळी upgrade होतात, आणि जुन्या पद्धतींना end date आहे.
- [ ] फक्त login service password hashes वाचू शकते; मोठं export झालं तर alert येतो.
- [ ] Code platform आणि CI tokens short-lived आहेत, आणि workflow changes ला review लागतो.
- [ ] User म्हणून: प्रत्येक app साठी वेगळा password, तो password manager मध्ये ठेवा, आणि breach notice आली तर लगेच बदला.
- [ ] API keys किंवा recovery phrases कधीच task notes किंवा comments मध्ये ठेवू नका.
Source: Todoist, "Security incident in नोव्हेंबर 2026" (help centre notice), 25 नोव्हेंबर 2026; TechCrunch, "Todoist confirms 6% of customers’ details were stolen in data breach", 25 नोव्हेंबर 2026.
1. क्या हुआ
इस lesson में आपने सीखा कि passwords हमेशा bcrypt या Argon2 जैसे slow password hash से store करने चाहिए, SHA-1 जैसे fast hash से नहीं. यह घटना क्यों ज़रूरी है? क्योंकि एक असली company के पास कुछ users के पुराने SHA-1 hashes अभी भी थे, और attacker उन्हें ले गया.
- Todoist एक popular to-do list और task app है.
- Todoist कहता है कि 22 और 23 नवंबर 2026 के बीच एक attacker ने उसके version control system का चोरी हुआ credential इस्तेमाल किया. उससे उसने तीन repositories के automated workflows बदले और और credentials हासिल किए. वह source code भी पढ़ सकता था. Todoist को app code में कोई बदलाव नहीं मिला.
- उनमें से एक credential से attacker यह बदल सका कि employees internal systems में कैसे sign in करते हैं. उसने एक employee का work account कब्ज़े में लिया और Todoist के cloud infrastructure तक पहुँचा.
- 23 नवंबर को attacker ने कुछ पुराने users की file download की, जिनके passwords अभी भी पुराने तरीके, यानी salted SHA-1 से store थे. उसमें email addresses, password hashes और account बनने की date थी. यह लगभग 6% users थे. Todoist को कोई संकेत नहीं मिला कि attacker ने उन accounts में sign in किया.
- बहुत छोटे groups के लिए attacker ने Todoist API tokens और Slack integration tokens लिए, कुछ customer content में credentials खोजे, और connected Todoist for Outlook accounts से email details पढ़े.
- ये पुराने hashes इसलिए बचे रहे क्योंकि उन users ने Todoist के SHA-1 बंद करने के बाद, यानी दस साल से ज़्यादा समय से, password नहीं बदला था. Todoist ने कहा कि इसे पहले ही बंद कर देना चाहिए था, और अब कर दिया है.
- Todoist ने attack के रास्ते block किए, expose हुए internal credentials बदले और affected accounts protect किए. पहला credential कैसे चोरी हुआ, यह अभी पता नहीं चला; उनका मुख्य अंदाज़ा है कि किसी employee का device compromise हुआ था, पर यह confirm नहीं है.
2. Hack कैसे हुआ (सिर्फ़ public reporting – high-level)
- Attacker के पास Todoist के code platform का चोरी हुआ credential था.
- उसने तीन repositories के automated workflows (CI jobs) बदले, ताकि और credentials इकट्ठे हो सकें.
- उनमें से एक credential से employee sign-in settings बदली जा सकीं, इसलिए उसने एक employee का work account कब्ज़े में ले लिया.
- वहाँ से वह cloud और production systems तक पहुँचा.
- उसने पुराने salted SHA-1 password hashes की file और कुछ tokens download किए.
- यह क्यों खतरनाक है: SHA-1 fast है. Fast hash पर attackers offline एक second में बहुत सारे password guesses try कर सकते हैं, इसलिए weak या दोबारा इस्तेमाल किए गए passwords खतरे में आते हैं.
3. इसे कैसे रोकें / defend करें (यह lesson: hashing, salts और password storage)
क्यों: Salt की वजह से एक guess एक साथ कई users पर नहीं चलता, पर सिर्फ़ slow hash ही हर guess को महँगा बनाता है.
Team क्या कर सकती है:
- Slow password hash इस्तेमाल करें: Argon2, bcrypt या scrypt, अच्छे work factor के साथ.
- पुराने hashes upgrade करें. User sign in करे तब पुराना hash check करें और तुरंत नया Argon2 या bcrypt hash save करें.
- पुराने तरीकों की end date रखें. जो users फिर sign in नहीं करते, उन्हें forced password reset दें, ताकि कोई SHA-1 hash सालों तक न बचे.
- Password table तक पहुँचना मुश्किल रखें. सिर्फ़ login service उसे पढ़े, और बड़ा export हो तो alert आए.
- Production तक का रास्ता भी protect करें: code और CI के लिए short-lived tokens, और workflows के हर change पर review.
Example: "पुराना hash" गिनने का आसान drill.
- Rule: store किया हर password Argon2 या bcrypt इस्तेमाल करता है.
- Action: गिनें कि कितने user records अभी भी कोई दूसरा hash type इस्तेमाल करते हैं (हर hash की शुरुआत में आमतौर पर उसका type दिखता है).
- Check: यह आँकड़ा zero होना चाहिए. नहीं है तो अगले sign-in पर upgrade करें और बाकी के लिए reset date तय करें.
- मतलब: database कभी leak हो भी जाए, तो attackers को सिर्फ़ slow, guess करने में मुश्किल hashes मिलते हैं.
4. फिर से ऐसा न हो, इसके लिए ध्यान (checklist)
- [ ] सभी passwords Argon2, bcrypt या scrypt से store होते हैं.
- [ ] पुराने hashes sign-in के समय upgrade होते हैं, और पुराने तरीकों की end date है.
- [ ] सिर्फ़ login service password hashes पढ़ सकती है; बड़ा export हो तो alert आता है.
- [ ] Code platform और CI tokens short-lived हैं, और workflow changes पर review ज़रूरी है.
- [ ] User के तौर पर: हर app के लिए अलग password, उसे password manager में रखें, और breach notice आए तो तुरंत बदलें.
- [ ] API keys या recovery phrases कभी task notes या comments में न रखें.
Source: Todoist, "Security incident in नवंबर 2026" (help centre notice), 25 नवंबर 2026; TechCrunch, "Todoist confirms 6% of customers’ details were stolen in data breach", 25 नवंबर 2026.
Ravindra Bagale's Tip
A salt is not enough. Ask your team one question: "Which hash do our oldest users still have?" If the answer is SHA-1 or MD5, upgrade at next sign-in and force a reset for the rest. Old hashes are a time bomb.
Ravindra Bagale's Tip – मराठी
फक्त salt पुरेसं नाही. Team ला एकच प्रश्न विचारा: "आपल्या सगळ्यात जुन्या users कडे अजून कोणता hash आहे?" उत्तर SHA-1 किंवा MD5 असेल, तर पुढच्या sign-in ला upgrade करा आणि बाकीच्यांना reset करायला लावा. जुने hashes म्हणजे time bomb.
Ravindra Bagale's Tip – हिंदी
सिर्फ़ salt काफ़ी नहीं है. Team से एक सवाल पूछें: "हमारे सबसे पुराने users के पास अभी भी कौन-सा hash है?" अगर जवाब SHA-1 या MD5 है, तो अगले sign-in पर upgrade करें और बाकी के लिए reset ज़रूरी करें. पुराने hashes एक time bomb हैं.
Check if you're safe: Password Strength Checker