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.

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.”

Advertisement. Scroll to continue reading.
Written By

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

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 event as we dive into threat hunting tools and frameworks, and explore value of threat intelligence data in the defender’s security stack.

Register

Learn how integrating BAS and Automated Penetration Testing empowers security teams to quickly identify and validate threats, enabling prompt response and remediation.

Register

People on the Move

Raffi Joukhadarian has been named Managing Director and Chief Financial Officer at MorganFranklin Cyber.

Data security firm Rubrik has appointed Kavitha Mariappan as its Chief Transformation Officer.

DARPA veteran Dan Kaufman has joined Badge as SVP, AI and Cybersecurity.

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.