Virtual Event: CodeSecCon - Learn to Secure Your Software > View Sessions
Connect with us

Hi, what are you looking for?

SecurityWeekSecurityWeek

Application Security

MySQL Authentication Bypass Offers Lesson for Developers

Last month, a spotlight was put on a MySQL authentication bypass vulnerability that gave hackers a one out of 256 chance to gain access to the database regardless of whether or not they entered the wrong password. Versions of MariaDB were also affected by the bug, which Rapid7’s HD Moore at the time called “tragically comedic.” However, application firm Coverity said the situation also presents a learning opportunity for developers.

Last month, a spotlight was put on a MySQL authentication bypass vulnerability that gave hackers a one out of 256 chance to gain access to the database regardless of whether or not they entered the wrong password. Versions of MariaDB were also affected by the bug, which Rapid7’s HD Moore at the time called “tragically comedic.” However, application firm Coverity said the situation also presents a learning opportunity for developers.

According to Coverity CTO Andy Chou, one of the company’s engineers wrote a static analysis checker to find truncation of memcmp, strcmp and stmcmp return values or cases whether the return value was tested against constraints other than zero. After running the checker over 6,286 open source projects totaling more than 330 million lines of code, they found 15 other defects along the same lines of the one found in MySQL.

The packages examined by Coverity were versions of: Nmap, Nawm, Olsrd, Ncbi-tools, OpenBabel, Wine, Yersinia and Gambas. Each of the packages was from a Debian 5.0 distribution, and many of the issues have either been fixed or have a patch on the way. Still, developers can avoid these types of bugs altogether by not truncating the return value when it comes to using comparison functions like memcmp and strcmp, Chou argued in a blog post detailing the findings.

“These bugs are all caused by misunderstanding the behavior of functions that compare memory regions or strings,” he explained to SecurityWeek. “The problem is that the value returned from these comparison functions is sometimes misunderstood by developers, so they make mistakes like thinking these functions can return only -1, 0, or 1.  Or, they might think the return value can be safely cast to a smaller type such as char, but they don’t realize that the truncation of the value might result in two memory regions being considered equal when they aren’t.”

“If these memory regions represent password hashes, this can lead to a vulnerability like the one in MySQL (CVE-2012-2122),” he said.

Some of the bugs could be classified as integer truncation issues that result in authentication bypass, but the effect from a security standpoint depends on where the defect occurs in the code, he said. In most cases, Coverity found potential for program logic errors, but not actual security vulnerabilities.

Advertisement. Scroll to continue reading.

The good news is these bugs are very rare, he said.

” We only found 16 defect instances in 330 million lines of code – that’s only one bug per 20 million lines of code,” Chou noted. “When they do make mistakes, they often think that these functions might only return -1, 0, or 1 because that’s actually true on some platforms. Unfortunately, it’s not true everywhere.”

Written By

Marketing professional with a background in journalism and a focus on IT security.

Daily Briefing Newsletter

Subscribe to the SecurityWeek Email Briefing for the latest cybersecurity threats, trends, and expert insights.

Click to comment

Trending

Daily Briefing Newsletter

Subscribe to the SecurityWeek Email Briefing to stay informed on the latest threats, trends, and technology, along with insightful columns from industry experts.

Join this live webinar as we explore if detection-first security operations can keep pace with AI, or if it’s time to rethink prevention as the strongest default.

Register

CodeSecCon bridges the gap between dev and security. Discover best practices for secure coding, innovative risk-reduction tools, and safe AI integration to cultivate a true DevSecOps culture. Safely secure your apps!

Register

People on the Move

UltraViolet Cyber has named Andrew Park Chief Information Security Officer.

Glow has appointed Patti Degnan as Chief Information Security Officer.

Daniel Dubowski has been named Senior Vice President and Chief Information Security Officer at Marriott International.

More People On The Move

Expert Insights

Daily Briefing Newsletter

Subscribe to the SecurityWeek Email Briefing to stay informed on the latest cybersecurity news, threats, and expert insights. Unsubscribe at any time.