Facebook Google Plus Twitter LinkedIn YouTube RSS Menu Search Resource - BlogResource - WebinarResource - ReportResource - Eventicons_066 icons_067icons_068icons_069icons_070

CODESYS V3 Denial of Service

High

Synopsis

When the CODESYS V3 runtime allocates memory for channel buffers, it reads the MaxChannels and BufferSize settings under the [CmpChannelServer] section in the configuration file (i.e., CODESYSControl.cfg, Gateway.cfg). The integer settings in the configuration file are treated as signed int32. If BufferSize is a large positive number (i.e, 0x7fffffff) and MaxChannels * 2 is a negative number (i.e., MaxChannels = 0x7fffffff), it will cause the runtime to allocate a large number of bytes (i.e., 0x7ffff008) from the heap. This could cause SysMemAllocData() to fail, resulting in an error in the log:

01571694396373, 0x0000000a, 4, 17, 0, Failed to allocate memory for channel buffers, no communication channels available

When the channel layer (layer 4) is not available, layer 7 services cannot be run, severely limiting the runtime functionalities.

Additionally, we reported a bug that CODESYS has deemed to be an improvement:

GatewayService.exe implements layer 7 service group 6, which allows manipulation (i.e., get, set, remove operations) of settings in the gateway configuration file. To access the layer 7 services, a valid session ID is required. It looks like an unauthenticated, remote attacker could login as an anonymous user to obtain a session ID. On a PLC (i.e., CODESYSControlService.exe) that also implements service group 6, the CmpUserMgr component is seen to be included in the runtime to prevent anonymous access. However, it does not appear the CmpUserMgr component is implemented in GatewayService.exe. So it's unclear whether GatewayService.exe can be configured to prevent an unauthenticated remote attacker from changing the configuration file.

When combining both issues, an unauthenticated remote attacker can cause a DoS on GatewayService.exe when it restarts.

The attached PoC attempts to write the following settings to Gateway.cfg:

[CmpChannelServer]
MaxChannels=2147483647
BufferSize=2147483647

Solution

Upgrade to V3.5.15.30.

Proof of Concept

https://github.com/tenable/poc/blob/master/codesys/codesys_gateway_v3_config_modification_tra_2020_04.py

Disclosure Timeline

10/29/2019 - Tenable reports vulnerabilities. 90-day date is 01/28/2020.
10/31/2019 - CODESYS will investigate. Asks if we would like to be acknowledged in the same fashion as last time.
10/31/2019 - Tenable acknowledges. This is fine.
11/19/2019 - Tenable asks for an update.
11/20/2019 - CODESYS says they are still investigating.
11/20/2019 - Tenable thanks CODESYS for update.
12/03/2019 - Tenable asks for an update.
12/05/2019 - CODESYS is "on track". They have scheduled a fix internally, and they will provide an updated timeline just before Christmas.
12/05/2019 - Tenable acknowledges.
12/19/2019 - CODESYS will fix the "Negative MaxChannels DoS" in the next patch release. The other bug is considered an improvement and not a vulnerability, so it will be fixed in the next main version. They will provide the advisory as soon as it is avail
12/19/2019 - Tenable asks for the anticipated advisory release date.
01/09/2020 - Tenable follows up.
01/09/2020 - CODESYS plans to release a fix and advisory around Jan 28.
01/21/2020 - Tenable follows up.
01/22/2020 - CODESYS has a release scheduled for 1/24. They will send a link to their advisory as soon as it is public.
01/22/2020 - Tenable acknowledges. We will publish our advisory once the patch is public.
01/23/2020 - CODESYS notifies tenable of advisory and bug fix releases.

All information within TRA advisories is provided “as is”, without warranty of any kind, including the implied warranties of merchantability and fitness for a particular purpose, and with no guarantee of completeness, accuracy, or timeliness. Individuals and organizations are responsible for assessing the impact of any actual or potential security vulnerability.

Tenable takes product security very seriously. If you believe you have found a vulnerability in one of our products, we ask that you please work with us to quickly resolve it in order to protect customers. Tenable believes in responding quickly to such reports, maintaining communication with researchers, and providing a solution in short order.

For more details on submitting vulnerability information, please see our Vulnerability Reporting Guidelines page.

If you have questions or corrections about this advisory, please email [email protected]

Try for Free Buy Now

Try Tenable.io

FREE FOR 30 DAYS

Enjoy full access to a modern, cloud-based vulnerability management platform that enables you to see and track all of your assets with unmatched accuracy. Sign up now.

Buy Tenable.io

Enjoy full access to a modern, cloud-based vulnerability management platform that enables you to see and track all of your assets with unmatched accuracy. Purchase your annual subscription today.

65 assets

Choose Your Subscription Option:

Buy Now
Try for Free Buy Now

Try Nessus Professional Free

FREE FOR 7 DAYS

Nessus® is the most comprehensive vulnerability scanner on the market today. Nessus Professional will help automate the vulnerability scanning process, save time in your compliance cycles and allow you to engage your IT team.

Buy Nessus Professional

Nessus® is the most comprehensive vulnerability scanner on the market today. Nessus Professional will help automate the vulnerability scanning process, save time in your compliance cycles and allow you to engage your IT team.

Buy a multi-year license and save. Add Advanced Support for access to phone, community and chat support 24 hours a day, 365 days a year. Full details here.

Try for Free Buy Now

Try Tenable.io Web Application Scanning

FREE FOR 30 DAYS

Enjoy full access to our latest web application scanning offering designed for modern applications as part of the Tenable.io platform. Safely scan your entire online portfolio for vulnerabilities with a high degree of accuracy without heavy manual effort or disruption to critical web applications. Sign up now.

Buy Tenable.io Web Application Scanning

Enjoy full access to a modern, cloud-based vulnerability management platform that enables you to see and track all of your assets with unmatched accuracy. Purchase your annual subscription today.

5 FQDNs

$3,578

Buy Now

Try for Free Contact Sales

Try Tenable.io Container Security

FREE FOR 30 DAYS

Enjoy full access to the only container security offering integrated into a vulnerability management platform. Monitor container images for vulnerabilities, malware and policy violations. Integrate with continuous integration and continuous deployment (CI/CD) systems to support DevOps practices, strengthen security and support enterprise policy compliance.

Buy Tenable.io Container Security

Tenable.io Container Security seamlessly and securely enables DevOps processes by providing visibility into the security of container images – including vulnerabilities, malware and policy violations – through integration with the build process.

Get a Demo of Tenable.sc

Please fill out the form below with your contact information and a sales representative will contact you shortly to schedule a demo. You may also include a short comment (limited to 255 characters). Please note that fields with asterisks (*) are mandatory.

Try for Free Contact Sales

Try Tenable Lumin

FREE FOR 30 DAYS

Visualize and explore your Cyber Exposure, track risk reduction over time and benchmark against your peers with Tenable Lumin.

Buy Tenable Lumin

Contact a Sales Representative to see how Lumin can help you gain insight across your entire organization and manage cyber risk.

Request a demo of Tenable.ot

Get the Operational Technology Security You Need.
Reduce the Risk You Don’t.