Security Vulnerabilities in Python
Security Vulnerability refers to the quality or state of being exposed to the possibility of being attacked or harmed. When developing an application or writing code, mistakes or security violations may occur. As a developer, we need to consider security vulnerabilities and then should start writing the code.
Below are the types of security vulnerabilities that Python developers should be concerned about:
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:
- In-band SQL Injection / Classic SQLi
- Inferential / Blind SQL injection
- DBMS SQLi
- Compounded SQLi (Eg: Strom Worn)
- SQLi with inadequate authentication
- SQLi with DDoS attacks
- SQLi with DNS hijacking
- 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 act by another logged-in user like clicking on a button. Also, it includes hacking or logging into a website with others’ login credentials.
LDAP (LIGHTWEIGHT DIRECTORY ACCESS PROTOCOL) INJECTIONS
This vulnerability occurs when a malicious user inserts/modify LDAP statements that lead to speculations.
Here, a malicious user executes OS commands on a web server by abusing it to insert their commands to gain complete control over the server.
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.
Python Taint (PYT) — Static Analysis Tool: This utility is used for identifying command injection, XSS, SQLi, interprocedural, and 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.
Tinfoil Security Website Scanner: Tinfoil is an affordable security scanner for Python & Django that helps find holes in web servers and applications and also tells you the ways to fix them.
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 the source, we can use the command python setup.py install after downloading the PyPI source tarball.
Pyntch — Static Code Analyzer: Pyntch (PYthoN Type CHecker) helps in detecting runtime errors such as exceptions, not found attributes, and variable type mismatching. It supports Python 2. x currently. It won’t address style issues like Pychecker or Pyflakes, but it works pretty fast and efficiently in scanning thousands of lines within a minute.
Spaghetti Security Scanner: Spaghetti is 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.
For more info: https://skolaparthi.com/security-vulnerabilities-in-python/