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

The iPhone Air might be proving a tough sell to customers
Gadget
The “Super AI” Is Breaking Up Wall Street’s Cozy Cartel
News
Google confirms when Android 16 QPR2 Beta 3 will return (Update: It’s back)
News
AI Is Changing What High School STEM Students Study
Gadget

You Might also Like

Computing

AI2 Incubator spinout Casium raises $5M to simplify work visa filings

4 Min Read
Computing

Patches Posted To Allow Hibernation Cancellation On Linux

2 Min Read
Computing

Social media management: The 2025 expert playbook

91 Min Read
Computing

Gold and Silver Soar as Bitcoin’s “Uptober” Turns into a Crash | HackerNoon

5 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?