• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer

Sucuri Blog

Website Security News

Main navigation

  • Products
    • Complete Website Security
    • Sucuri Firewall
  • Industry
    • Enterprise Solutions
    • Agency Solutions
    • Education Solutions
  • Languages
    • English
    • Spanish
    • Portuguese
  • Are You Under Attack?
    • Clean Hacked SiteMy site has malware, is Blacklisted or Hacked
    • Protect My SiteMy site is under attack (ie: DDoS, Brute Force)
  • Login
  • 1–888–873–0817
  • Facebook
  • Twitter
  • Instagram

SQL Injection Vulnerability in Joomla! 3.7

May 17, 2017Marc-Alexandre MontpasEspanol

Security Risk: Severe

Exploitation Level: Easy/Remote

DREAD Score: 8.6/10

Vulnerability: SQL Injection

Patched Version: 3.7.1

During regular research audits for our Sucuri Firewall (WAF), we discovered a SQL Injection vulnerability affecting Joomla! 3.7 – CVE-2017-8917. The vulnerability is easy to exploit and doesn’t require a privileged account on the victim’s site.

Are You at Risk?

The vulnerability is caused by a new component, com_fields, which was introduced in version 3.7. If you use this version, you are affected and should update as soon as possible. This vulnerable component is publicly accessible, which means this issue can be exploited by any malicious individual visiting your site.

Given the nature of SQL Injection attacks, there are many ways an attacker could cause harm – examples include leaking password hashes and hijacking a logged-in user’s session (the latter results in a full site compromise if an administrator session is stolen).

Technical Details

The public-facing com_fields component borrows some views from the administrative side component of the same name. While this may sound like an odd thing to do, it serves a very practical purpose – it allows the reuse of generic code that was written for the other side, instead of writing it from scratch again.

As you can see from the snippet above, it sets the $config[‘base_path’] variable with the JPATH_COMPONENT_ADMINISTRATOR constant value which represents the local path to the administrator component directory. Doing this will cause Joomla! to grab views and models from this path instead of the public facing one. As this action is conditional to the view parameter containing fields and layout to contain modal, we know the URL to access this view must look like this:

/index.php?option=com_fields&view=fields&layout=modal

Visiting this URL leads to a listing of all the custom fields available on the site which can be ordered based on various parameters.

The only administrator view that can be accessed is fields – and this will grab its data from an admin-side model (due to the $config[‘base_path’] trick we discussed earlier). In this case, the vulnerability we discovered was located in the FieldsModelFields model, in ./administrator/components/com_fields/models/fields.php.

The culprit can be found in the getListQuery method.

For those not familiar with how Joomla! deals with SQL queries, the $query->order() really is just a method whose input will be concatenated to a query’s ORDER BY statement, so you can guess that leaving non-sanitized user input in there is the last thing you want. Unfortunately, this is exactly what happened.

The list.fullordering state can be populated with user input because the FieldsModelFields model inherits from the JModelList class, which contains the snippet above. You may notice that it performs some verification on the content and then sets the list.direction and list.ordering state accordingly, but what about list.fullordering?

After the switch statement, this instruction sets the state we were looking for with a value that we can control, regardless of whether it generated a valid list.direction or list.ordering state.

So in order to exploit this vulnerability, all an attacker has to do is  add the proper parameters to the URL in order to inject nested SQL queries.

In Conclusion

If you have not already, update as soon as possible!

This is a serious vulnerability that can be misused in different ways to compromise a vulnerable site. Update now. If you believe your Joomla site is hacked, you can follow our free DIY cleanup guide.

Categories: Joomla Security, Vulnerability DisclosureTags: SQL Injection

About Marc-Alexandre Montpas

Marc's passion for code and IT security has no limit. You'll generally find him competing in Capture-the-Flag (CTF) competitions or searching for security vulnerabilities in widespread products for the fun of it. He's also a great fan of heavy metal music. Follow him on Twitter at @marcs0h.

We no longer support comments on our blogs. If you’d like to continue the conversation, engage with us via Twitter at @sucurisecurity and @sucurilabs. If you have recommendations or questions that require more than 140 characters, please send us an email at info@sucuri.net.

Primary Sidebar

Socialize With Sucuri

We're actively engaged across multiple platforms. Follow us and let's connect!

  • Facebook
  • Twitter
  • LinkedIn
  • YouTube
  • Instagram
  • RSS Feed

Sucuri website security guides

Join Over 20,000 Subscribers!

Enter your email below to get Sucuri's latest vulnerability disclosures, blog posts, and news via email.

Language

Footer

Products

  • Website Firewall
  • Website AntiVirus
  • Website Backups
  • WordPress Security
  • Enterprise Services

Solutions

  • DDos Protection
  • Malware Detection
  • Malware Removal
  • Malware Prevention
  • Blacklist Removal

Support

  • Blog
  • Knowledge Base
  • SiteCheck
  • Research Labs
  • FAQ

Company

  • About
  • Media
  • Events
  • Employment
  • Contact
  • Testimonials
  • Facebook
  • Twitter
  • LinkedIn
  • Instagram

Customer Login

Sucuri Home

  • Terms of Use
  • Privacy Policy
  • Frequently Asked Questions

© 2017 Sucuri Inc. All rights reserved