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

Tenable Blog

Subscribe

Python NaN Injection

In Python, a NaN can cause a slew of errors leading to numerous failure conditions. Test for NaNs using a white-box scenario to avoid fallout.

Python is often referred to as “type-safe” by people who aren’t aware of the fact that it is actually “duck typed.” Meaning, that in Python, if the variable ‘walks like a duck and talks like a duck, it must be a duck.’ However, a variable can be injected with a string called NaN (which stands for Not a Number) and when it encounters another variable, it can consume it. For instance, a numeric integer like the number 1 can be added to a float that contains a NaN and the output will be a NaN. NaN then becomes extremely greedy.

Further complicating matters, there are many ways to get to NaN, including a simple division of a positive and negative infinity. And, worse yet, infinity can be reached through the addition of non-infinite real numbers such as 1e308 + 1e308. In this way, there are several ways to create infinity, negative infinity, and ultimately, NaN in Python. Further, there is a negative integer overflow on the Ubuntu/FreeBSD implication of NumPy (v1.21) in the presence of NaN as it is cast to an int.

Python (as of 3.6.9) has several issues that cause subsequent problems such as failing to be IEEE754 compliant, as well as broken sorting functions that can lead to many failure conditions, authentication backdoors, denial of service, privilege escalation, runaway processes, and general logic flaws. Therefore, the actual damage potential is extremely difficult to know in advance.

Tenable and NTT Application Security recommend not testing for this issue in a black-box production environment due to how dangerous the testing can be. It should be tested only in pre-production and ideally in a white-box scenario so that all elements can be exercised. Careful use of isnan() on all elements that are consumed should be the standard fix outside of a broad fix.

Testing for the presence of Python, on the other hand, can be safely accomplished through various known Python application headers, predictable URL locations of known Python applications and Python-specific error messages. That said, NaN Injection can surface within applications that leverage back-end cron jobs, or APIs that may be hidden from an external assessment. There is no known WAF or IDS rule to prevent NaN Injection as of the time of writing.

For more details, please see the git repository.

Visit the Tenable.asm product page to learn more about attack surface management.

Related Articles

Are You Vulnerable to the Latest Exploits?

Enter your email to receive the latest cyber exposure alerts in your inbox.

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.

tenable.io BUY

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

Select Your License

Buy a multi-year license and save.

Add Support and Training

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.

Tenable.io BUY

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 Tenable.io Web Application Scanning

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 Tenable.io Container Security

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.

Try Tenable Lumin

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.

Try Tenable.cs

Enjoy full access to detect and fix cloud infrastructure misconfigurations and view runtime vulnerabilities. Sign up for your free trial now.

Contact a Sales Rep to Buy Tenable.cs

Contact a Sales Representative to learn more about Tenable.cs Cloud Security and see how easy it is to onboard your cloud accounts and get visibility into both cloud misconfigurations and vulnerabilities within minutes.

Try Nessus Expert Free

FREE FOR 7 DAYS

Built for the modern attack surface, Nessus Expert enables you to see more and protect your organization from vulnerabilities from IT to the cloud.

Already have Nessus Professional?
Upgrade to Nessus Expert free for 7 days.

Buy Nessus Expert

Built for the modern attack surface, Nessus Expert enables you to see more and protect your organization from vulnerabilities from IT to the cloud.

Select Your License

Buy a multi-year license and save.

Add Support