By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
World of SoftwareWorld of SoftwareWorld of Software
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Search
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright ยฉ All Rights Reserved. World of Software.
Reading: Code Smell 311 – Never Store or Compare Plain-text Passwords | HackerNoon
Share
Sign In
Notification Show More
Font ResizerAa
World of SoftwareWorld of Software
Font ResizerAa
  • Software
  • Mobile
  • Computing
  • Gadget
  • Gaming
  • Videos
Search
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Have an existing account? Sign In
Follow US
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright ยฉ All Rights Reserved. World of Software.
World of Software > Computing > Code Smell 311 – Never Store or Compare Plain-text Passwords | HackerNoon
Computing

Code Smell 311 – Never Store or Compare Plain-text Passwords | HackerNoon

News Room
Last updated: 2025/10/20 at 12:15 PM
News Room Published 20 October 2025
Share
SHARE

Your login isn’t secure if you store secrets in plain sight

TL;DR: Never store or compare plain-text passwords

Problems ๐Ÿ˜”

  • Data exposure
  • Weak security
  • User trust loss
  • Compliance issues
  • Easy exploitation
  • Authentication bypass potential

Solutions ๐Ÿ˜ƒ

  1. Hash user passwords
  2. Use strong algorithms
  3. Salt every hash
  4. Compare hashes safely
  5. Secure your database
  6. Perform regular penetration tests

Context ๐Ÿ’ฌ

When you store or compare passwords as plain-text, you expose users to unnecessary risk.

A data breach will instantly reveal every credential.

Attackers can reuse these passwords on other sites. Even internal logs or debugging can leak sensitive data.

You must treat passwords as secrets, not as values to display or compare directly.

Sample Code ๐Ÿ“–

Wrong โŒ

// Borrowed from "Beyond Vibe Coding"

app.post('/login', async (req, res) => {
  const { username, password } = req.body;
  const user = await Users.findOne({ username });
  if (!user) return res.status(401).send("No such user");
  if (user.password === password) {
    res.send("Login successful!");
  } else {
    res.status(401).send("Incorrect password");
  }
});

Right ๐Ÿ‘‰

import bcrypt from 'bcrypt';

app.post('/login', async (req, res) => {
  const { username, password } = req.body;
  const user = await Users.findOne({ username });
  if (!user) return res.status(401).send('Invalid credentials');
  const valid = await bcrypt.compare(password, user.password);
  if (!valid) return res.status(401).send('Invalid credentials');
  res.send('Login successful');
});

Detection ๐Ÿ”

  • Semi-Automatic

You can detect this smell when you see passwords handled as raw strings, compared directly with ===, or stored without hashing.

Static analyzers and linters can catch unsafe password handling, but code reviews remain the best defense.

Tags ๐Ÿท๏ธ

  • Security

Level ๐Ÿ”‹

  • Beginner

Why the Bijection Is Important ๐Ÿ—บ๏ธ

In the MAPPER, passwords represent sensitive user credentials that must remain confidential.

The bijection breaks when you store passwords as plain-text because real-world security expectations don’t match your system’s actual protection.

Users trust you to protect their credentials.

When you store plain-text passwords, you create a false representation where the system appears secure but actually exposes sensitive data.

This broken mapping between user expectations and system reality leads to security breaches and loss of trust.

When you design your authentication system, you create a mapping between a MAPPER concept โ€” a “userโ€™s identity” โ€” and your programโ€™s data.

Hashing preserves that bijection safely.

When you break it by storing raw passwords, your system represents users incorrectly: it turns their private identity into an exposed string.

That breaks trust and control.

AI Generation ๐Ÿค–

AI code generators sometimes create login examples comparing plain-text passwords.

The code sample is from the book Beyond Vibe Coding in the chapter about “8. Security, Maintainability, and Reliability”.

These examples look simple, but they spread insecure habits.

You must always validate and adapt AI-generated authentication code.

AI Detection ๐Ÿงฒ

AI tools can detect this smell when you provide context about security requirements.

They recognize patterns of plain-text password comparison and can suggest proper hashing implementations.

You need to ask AI to review the authentication code for security vulnerabilities to get comprehensive fixes.

Try Them! ๐Ÿ› 

Remember: AI Assistants make lots of mistakes

Suggested Prompt: Refactor this login code to securely hash and compare passwords

| Without Proper Instructions | With Specific Instructions |
|—-|—-|
| ChatGPT | ChatGPT |
| Claude | Claude |
| Perplexity | Perplexity |
| Copilot | Copilot |
| You | You |
| Gemini | Gemini |
| DeepSeek | DeepSeek |
| Meta AI | Meta AI |
| Grok | Grok |
| Qwen | Qwen |

Conclusion ๐Ÿ

Plain text passwords are a trap.

You make your users unsafe and invite catastrophic leaks. You must always hash, salt, and compare securely.

The fix is simple, and the trust you earn is priceless.

Relations ๐Ÿ‘ฉโ€โค๏ธโ€๐Ÿ’‹โ€๐Ÿ‘จ

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xxxviii

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xx-we-have-reached-100

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xliii

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xxxiv?embedable=true

https://hackernoon.com/code-smell-258-the-dangers-of-hardcoding-secrets

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xxxiv?embedable=true

https://hackernoon.com/code-smell-284-encrypted-functions?embedable=true

More Information ๐Ÿ“•

https://learning.oreilly.com/library/view/beyond-vibe-coding/9798341634749/ch08.html?embedable=true

Disclaimer ๐Ÿ“˜

Code Smells are my opinion.


If you think technology can solve your security problems, then you donโ€™t understand the problems and you donโ€™t understand the technology.

Bruce Schneier

https://hackernoon.com/400-thought-provoking-software-engineering-quotes?embedable=true


This article is part of the CodeSmell Series.

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-i-xqz3evd?embedable=true

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Twitter Email Print
Share
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article World’s biggest YouTube illegal ‘ripping’ sites visited by 620 MILLION shut down
Next Article Apple’s Stock Price Reaches New All-Time High
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

248.1k Like
69.1k Follow
134k Pin
54.3k Follow

Latest News

Some Truly Intelligent Savings: This Google Smart Speaker Is Now 31% Off
News
Zocdoc CEO: โ€˜Dr. Google is going to be replaced by Dr. AIโ€™
News
Microsoft hints at first-party Xbox handheld, but gamers must demand it | Stuff
Gadget
Context Is Your Competitive Advantage in the Age of AI
Computing

You Might also Like

Computing

Context Is Your Competitive Advantage in the Age of AI

16 Min Read
Computing

ChatGPT Is Not Just a Tool; It’s a Mirror for How You Think | HackerNoon

6 Min Read
Computing

AMD Announces “ROCm 7.9” As Technology Preview Paired With TheRock Build System

3 Min Read
Computing

Paradigm Towers turns IHSโ€™s Rwanda exit into a growth play

8 Min Read
//

World of Software is your one-stop website for the latest tech news and updates, follow us now to get the news that matters to you.

Quick Link

  • Privacy Policy
  • Terms of use
  • Advertise
  • Contact

Topics

  • Computing
  • Software
  • Press Release
  • Trending

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

World of SoftwareWorld of Software
Follow US
Copyright ยฉ All Rights Reserved. World of Software.
Welcome Back!

Sign in to your account

Lost your password?