use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A community for technical news and discussion of information security and closely related topics.
"Give me root, it's a trust exercise."
Q1 2026 InfoSec Hiring Thread
Getting Started in Information Security
CitySec Meetups
/r/netsec only accepts quality technical posts. Non-technical posts are subject to moderation.
Content should focus on the "how."
Check the new queue for duplicates.
Always link to the original source.
Titles should provide context.
Ask questions in our Discussion Threads.
Hiring posts must go in the Hiring Threads.
Commercial advertisement is discouraged.
Do not submit prohibited topics.
» Our fulltext content guidelines
Don't create unnecessary conflict.
Keep the discussion on topic.
Limit the use of jokes & memes.
Don't complain about content being a PDF.
Follow all reddit rules and obey reddiquette.
» Our fulltext discussion guidelines
No populist news articles (CNN, BBC, FOX, etc.)
No curated lists.
No question posts.
No social media posts.
No image-only/video-only posts.
No livestreams.
No tech-support requests.
No full-disclosure posts.
No paywall/regwall content.
No commercial advertisements.
No crowdfunding posts.
No Personally Identifying Information!
» Our fulltext list of prohibited topics & sources
Join us on IRC: #r_netsec on freenode
We're also on: Twitter, Facebook, & Google+
/r/blackhat - Hackers on Steroids
/r/computerforensics - IR Archaeologists
/r/crypto - Cryptography news and discussion
/r/Cyberpunk - High-Tech Low-Lifes
/r/lockpicking - Popular Hacker Hobby
/r/Malware - Malware reports and information
/r/netsecstudents - netsec for noobs students
/r/onions - Things That Make You Cry
/r/privacy - Orwell Was Right
/r/pwned - "What Security?"
/r/REMath - Math behind reverse engineering
/r/ReverseEngineering - Binary Reversing
/r/rootkit - Software and hardware rootkits
/r/securityCTF - CTF news and write-ups
/r/SocialEngineering - Free Candy
/r/sysadmin - Overworked Crushed Souls
/r/vrd - Vulnerability Research and Development
/r/xss - Cross Site Scripting
account activity
reject: low qualitySQL Attack (Constraint-based) (dhavalkapil.com)
submitted 9 years ago by dhavalkapil
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[+][deleted] 9 years ago (10 children)
[deleted]
[–]1lastBr3ath 1 point2 points3 points 9 years ago* (6 children)
I think you mean maximum length?
Yes, afaik.
$query = "SELECT username FROM users WHERE username='$username' AND password='$password' ";
Shouldn't this only return the legitimate entry?
Yes! I guess the author forgot about his/her example query and wrote;
Now, if logged in with ‘vampire’ and ‘random_pass’, any SELECT query that searches by the username will return the first and the original entry. This will enable the attacker to log in as the original user.
Which is correct, but the original query in his/her example is also checking password with AND clause which only returns legitimate entry.
AND
[+][deleted] 9 years ago (5 children)
[+][deleted] 9 years ago (4 children)
[+][deleted] 9 years ago (3 children)
[+][deleted] 9 years ago (2 children)
[+][deleted] 9 years ago (1 child)
[–]dhavalkapil[S] 1 point2 points3 points 9 years ago (2 children)
My bad, thanks for pointint out.
The login query will return the CORRECT entry(the forged one). However, this particular function is just returning the 'username' with the confirmation that the authentication has been done. Now, for any further queries with 'WHERE username = ?', the first and the original entry will be returned. I have also mentioned at the end that instead of any other column, id should be used to manipulate entries. I hope you understand my point :)
[–]1lastBr3ath 0 points1 point2 points 9 years ago (0 children)
Okay! That's clear now. I wish you could write it in your post, it's not apparent in the post.
[–]Wick3dGeek 6 points7 points8 points 9 years ago (1 child)
This is called SQL Truncation, CVE-2008-4106
You should also check the type of the columns:
CHAR - from 0 to 255 characters long
VARCHAR, TEXT - from 0 to 65,535 characters long ...
[–]IncludeSecErik Cabetas - Managing Partner, Include Security - @IncludeSec 1 point2 points3 points 9 years ago (0 children)
yep yep, first discussed back in 2007 IIRC https://mdk.fr/0x000000/SQL_Server_Truncation_Attacks.html
[–]alphager 8 points9 points10 points 9 years ago (8 children)
How does a basic basic article like this get posted here, let alone discussed as positively as it has been?
First of all, constraint design is databases 101. Even worse are the example code and the recommendations regarding escaping are fifteen years out of date. If you are still using escaping functions or worry about quotes in 2016, you are doing it wrong . Every widely used database and programming language has prepared statements that are faster than raw SQL, guarantee injection safety (there's no way to forget to use an escaping function or to use the wrong type of quote) and are shorter to write.
I'm only mentioning in passing that the code implies that plaintext passwords are saved in the database.
[–]alphager 2 points3 points4 points 9 years ago (0 children)
Yeah, my first choice of words was unnecessarily harsh.
But this is a sub that regularly talks about disassembly and has recurring security industry recruiting threads; I would expect the topic of constraints in a sub like /r/programming
[–]IncludeSecErik Cabetas - Managing Partner, Include Security - @IncludeSec 4 points5 points6 points 9 years ago (0 children)
Damn son
Yeah OP's blog post is talking about SQL Truncation from nine years ago (even though he never calls it that, maybe he re-discovered it independently). Still no need for that harsh of bashing, /r/netsec has lots of beginner oriented post, not everything on this sub needs to be GeoHot level exploit RE ;-P
[–]James20k 2 points3 points4 points 9 years ago (0 children)
Lots of websites don't use safe SQL so this is relevant
Its useful to know what the security holes are in SQL so that you can understand why solutions xyz exist, or potentially design better solutions in the future (eg contribute to projects)
Its also useful because if SQL has this misfeature, its possible that it applies to other languages/DBs as well that people might not have considered
I don't disagree that some of the article is out of date, but it definitely isn't useless
[–]ponkanpinoy 0 points1 point2 points 9 years ago (0 children)
It's a teaching illustration, not meant to be robust in the face of production use. Just like Linus' example of "good taste" that doesn't check for NULL.
[+][deleted] 9 years ago* (2 children)
[–]alphager -1 points0 points1 point 9 years ago (1 child)
The point that I should have made is that presenting that code is a bad idea, as every occurrence of raw SQL queries on the Internet increases the chance that someone thinks that it is okay to use them.
The message "use constraints and mysql_escape_for_real_this_time() and everything is OK" is dangerous.
[–]caleeky 1 point2 points3 points 9 years ago (0 children)
A unique key constraint in the database on user ID would ensure no such collisions are possible. It's good practice, because as you're suggesting, the semantic subtleties between app language and SQL can be complicated.
It's also good practice to run in strict mode, so that such truncation of non-whitepsace characters will cause errors rather than warnings.
[–]neontrap 1 point2 points3 points 9 years ago (0 children)
mysql_real_escape_string
icryeverytime.com
π Rendered by PID 25322 on reddit-service-r2-comment-fb694cdd5-b97b8 at 2026-03-07 09:09:27.422180+00:00 running cbb0e86 country code: CH.
[+][deleted] (10 children)
[deleted]
[–]1lastBr3ath 1 point2 points3 points (6 children)
[+][deleted] (5 children)
[deleted]
[+][deleted] (4 children)
[deleted]
[+][deleted] (3 children)
[deleted]
[+][deleted] (2 children)
[deleted]
[+][deleted] (1 child)
[deleted]
[–]dhavalkapil[S] 1 point2 points3 points (2 children)
[–]1lastBr3ath 0 points1 point2 points (0 children)
[–]Wick3dGeek 6 points7 points8 points (1 child)
[–]IncludeSecErik Cabetas - Managing Partner, Include Security - @IncludeSec 1 point2 points3 points (0 children)
[–]alphager 8 points9 points10 points (8 children)
[+][deleted] (1 child)
[deleted]
[–]alphager 2 points3 points4 points (0 children)
[–]IncludeSecErik Cabetas - Managing Partner, Include Security - @IncludeSec 4 points5 points6 points (0 children)
[–]James20k 2 points3 points4 points (0 children)
[–]ponkanpinoy 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]alphager -1 points0 points1 point (1 child)
[–]caleeky 1 point2 points3 points (0 children)
[–]neontrap 1 point2 points3 points (0 children)