Digging for Security Bugs / Vulnerabilities in Python Applications – Info CCrime

In the age of DevOps, application security is an increasing concern for organizations. But attention on application-specific security bugs is comparatively low. We have extensive online security scanners for testing online threats, but they are not so effective for detecting security that are application-specific in , Node.js and more.

Why Python?

In Python, we can create a prototype in a few minutes, whereas it can take days in other languages. Python’s core programming is secure, but the third-party components used for developing an application may not be. Hence we require a security scanner for checking if there are any vulnerabilities or bugs. It’s mandatory for all Python or Django developers who are working with huge databases containing highly secured data.


High Risk Python Security Vulnerabilities

Here are the types of security vulnerabilities that Python developers should be concerned with:

SQL Injections (SQLi)

A malicious user controls the execution of SQL statements for an application at the backend database server. There are four sub-classes in SQLi:

  1. In-band SQL Injection / Classic SQLi
  2. Inferential / Blind SQL injection
  3. DBMS SQLi
  4. Compounded SQLi (Eg: Strom Worn)
    1. SQLi with inadequate authentication
    2. SQLi with DDoS attacks
    3. SQLi with DNS hijacking
    4. SQLi with XSS

Cross Site Scripting (XSS)

In XSS, a malevolent user can trick any web application to steal stored cookies, saved passwords, and script code that served unsuspecting users of that application.

Cross Site Request Forgery (CSRF)

This security vulnerability occurs when a compromised website is forced to perform an action by another logged-in user like clicking on a button. Also, it includes the hacking or logging into of a website with others’ login credentials.

LDAP (Lightweight Directory Access Protocol) Injections

This vulnerability occurs when a malicious user inserts/modifies LDAP statements that lead to speculations.

Command Injections

Here, a malicious user executes OS commands on a web server by abusing it in order to insert their own commands to gain complete control over the server.

XPathi

This occurs when a malevolent user intentionally passes data to a website. They can use that interaction to find out how the data is structured in XML, or they can access secured data that they can’t access normally.


Security Scanners

Let’s have a close look security scanners for finding security vulnerabilities in Python applications.

  1. Python Taint (PYT) – Static Analysis Tool: This utility is used for identifying command injection, XSS, SQLi, interprocedural, path traversal HTTP attacks in Python web apps. Python Taint is based on the Control flow graphs, data flow analysis and fixed points that are theoretical foundations built using the Flask framework.
  2. Tinfoil Security Website Scanner:
  3. Bandit – AST Based Static Analyzer: It’s an OpenStack security linter that identifies the common security risks in Python programming. It is distributed using pip. To install bandit from source, we can use the command python setup.py install after downloading the pypi source tarball. You can even access the reports from bandit.
  4. Pyntch – Static Code Analyzer: Pyntch (PYthoN Type CHecker) helps in detecting runtime errors such as exceptions, not found attributes and variable type missmatchings. It supports Python 2.x currently. It won’t address style issues like Pychecker or Pyflakes, but it works pretty fast and efficient in scanning thousands of lines within a minute.
  5. Spaghetti Security Scanner: Spaghetti an open-source web application security scanner built on Python version 2.7. It detects default files, misconfigurations, and insecure files, and it supports numerous frameworks including Django, CherryPy, CakePHP, and others. The tool is capable of finding attacks like admin panel, cookie security, credit card/email/private IP disclosures, SQL injections, ShellShock, Struts-shock, Apache ModStatus, Anonymous cipher, and others.
  6. Rough Auditing Tools for Security (RATS): It’s a free tool that scans languages like C, C++, PHP, Perl and Python and emphasizes the errors that are related to security like TOC (Time of Check), TOU (Time of Use), Buffer overflows and Acunetix. Manual code introspection is still important, but this tool still greatly assists us.
  7. PyDbgEng – Windows Debugging Engine’s Python Wrapper: It helps in debugging user mode, kernel mode, software and hardware breakpoints, etc. With the help of this PyDbgEbg, you can do fault injection, fuzzing of applications, and unpacking executables automatically.
  8. python-ptrace: It’s an opensource debugging tool that uses ptrace developed and written in Python. Here, ptrace works as an tracer that hands the system calls in Linux, BSD and Darwin.
  9. vdb / vtrace – Debugger for Exploit Malware Analysis: Here, VDB refers to a dynamic debugging element; vtrace refers to a platform that’s used in debugging frameworks implemented in Python. Vdb utilizes vtrace.
  10. Immunity Debugger – Python Penetration Testing Tool: It uses python scripts and supports Windows with Graphical user interface and command line debuggers.
  11. Mona.py – Open Immunity Debugger: This a PyCommand that replaces the pvefindaddr and resolves performance issues.

The above-mentioned tools can help you find the security vulnerabilities in web applications created using Python.


About the Author: Tejaswini UL possesses a love and passion towards technology writing, which brought her into this field. Presently, she is working as a Lead at Mindmajix Technologies. During her career, she has contributed writing on many technology innovations. In her free time, she relishes in making handy crafts. She also loves working on Python Programming and sharing articles and tutorials about their usage.

Editor’s Note: The opinions expressed in this guest author article are solely those of the contributor, and do not necessarily reflect those of Tripwire, Inc.

Article Prepared by Ollala Corp

You might also like
Leave A Reply

Your email address will not be published.