You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Documentation is written in academic style to support security researchers while using in plain English to cater for an international audience.
7
6
8
-
This page is an initiative by the OpenSSF to improve secure coding in Python by providing a location for study. Its structure is based on
9
-
Common Weakness Enamurator (CWE) [Pillar Weakness](https://cwe.mitre.org/documents/glossary/#Pillar%20Weakness)[mitre.org 2023].
10
-
11
-
Some rules only contain code examples, documentation will follow.
7
+
Python modules outside of the _Python Module Index_[[Python 2023](https://docs.python.org/3.9/py-modindex.html)], languages such as `HTML` and `JavaScript` are avoided.
8
+
The structure is based on Common Weakness Enamurator (CWE) _Pillar Weakness_[[MTRE 2024][](https://cwe.mitre.org/documents/glossary/#Pillar%20Weakness)].
12
9
13
10
## Disclaimer
14
11
15
-
Content comes WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, as stated in the license text [CC-BY-4.0](LICENSE/CC-BY-4.0.txt) for documentation and [MIT](LICENSE/MIT.txt).
12
+
Content comes __WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED__, as stated in the license text [CC-BY-4.0](LICENSE/CC-BY-4.0.txt) for documentation and [MIT](LICENSE/MIT.txt).
16
13
Following or using the documentation and or code is at your own risk. Code examples are intended purely for educational use and not for products in parts or in full.
17
14
Code examples are NOT to be used to cause harm of any kind to anyone or anything.
18
15
19
16
## Introduction
20
17
21
18
Every person writing code shall study the following:
*OWASP Top 10 Report [OWASP 2022](https://owasp.org/www-project-top-ten/)[OWASP 2022]
25
-
*CWE Top 25 2022 [CWE 2022](https://cwe.mitre.org/top25/archive/2022/2022_cwe_top25.html)[MITRE 2023]
20
+
*_OWASP Developer Guide_[[OWASP dev 2024](https://owasp.org/www-project-developer-guide/release/)]
21
+
*_OWASP Top 10 Report_[[OWASP 2021](https://owasp.org/www-project-top-ten/)]
22
+
*_CWE Top 25_[[MITRE 2024](https://cwe.mitre.org/top25/index.html)]
26
23
27
24
## Secure Coding Standard for Python
28
25
29
-
Code examples are written to explain security design with as little code as possible demonstrating the issue in the `noncompliantXX.py` titled Python file.
30
-
The `compliantXX.py` file demonstrates only the mitigation or removal of the described risk.
31
-
None of the code examples are intendet to be used 'as is' for production. Using the code is at your own risk.
26
+
Code examples are written to explain security design with as little code as possible. __None__ of the code examples are intendet to be used 'as is' for production. Using the code is at your own risk!
27
+
28
+
__Code file naminng conventions:__
29
+
30
+
*`noncompliantXX.py` anti-pattern.
31
+
*`compliantXX.py` mitigation for mitigating or removal of __ONLY__ the described risk.
32
+
*`exampleXX.py` to allow understanding the documented behaviour.
32
33
33
-
It is **not production code** and requires code-style or python best practices to be added such as:
34
+
It is __not production code__ and requires code-style or python best practices to be added such as:
34
35
35
36
* Inline documentation
36
37
* Custom exceptions
@@ -41,20 +42,20 @@ It is **not production code** and requires code-style or python best practices t
41
42
42
43
|[CWE-664: Improper Control of a Resource Through its Lifetime](https://cwe.mitre.org/data/definitions/664.html)|Prominent CVE|
|[CWE-134: Use of Externally-Controlled Format String](CWE-664/CWE-134/README.md)|[CVE-2022-27177](https://www.cvedetails.com/cve/CVE-2022-27177/),<br/>CVSSv3.1: **9.8**,<br/>EPSS: **00.37** (01.12.2023)|
45
+
|[CWE-134: Use of Externally-Controlled Format String](CWE-664/CWE-134/README.md)|[CVE-2022-27177](https://www.cvedetails.com/cve/CVE-2022-27177/),<br/>CVSSv3.1: __9.8__,<br/>EPSS: __00.37__ (01.12.2023)|
|[CWE-502: Deserialization of Untrusted Data)](CWE-664/CWE-502/.)|[CVE-2018-8021](https://www.cvedetails.com/cve/CVE-2018-8021),<br/>CVSSv3.0: **9.8**,<br/>EPSS: **93.54** (05.11.2024)|
53
-
|[CWE-532: Insertion of Sensitive Information into Log File](CWE-664/CWE-532/README.md)|[CVE-2023-45585](https://www.cvedetails.com/cve/CVE-2023-45585),<br/>CVSSv3.1: **9.8**,<br/>EPSS: **0.04** (01.11.2024)|
|[CWE-502: Deserialization of Untrusted Data)](CWE-664/CWE-502/.)|[CVE-2018-8021](https://www.cvedetails.com/cve/CVE-2018-8021),<br/>CVSSv3.0: __9.8__,<br/>EPSS: __93.54__ (05.11.2024)|
54
+
|[CWE-532: Insertion of Sensitive Information into Log File](CWE-664/CWE-532/README.md)|[CVE-2023-45585](https://www.cvedetails.com/cve/CVE-2023-45585),<br/>CVSSv3.1: __9.8__,<br/>EPSS: __0.04__ (01.11.2024)|
|[CWE-681: Incorrect Conversion between Numeric Types](CWE-664/CWE-681/README.md)||
56
57
|[CWE-833: Deadlock](CWE-664/CWE-833/README.md)||
57
-
|[CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')](CWE-664/CWE-843/.)|[CVE-2021-29513](https://www.cvedetails.com/cve/CVE-2021-29513),<br/>CVSSv3.1: **7.8**,<br/>EPSS: **00.05** (05.11.2024)|
58
+
|[CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')](CWE-664/CWE-843/.)|[CVE-2021-29513](https://www.cvedetails.com/cve/CVE-2021-29513),<br/>CVSSv3.1: __7.8__,<br/>EPSS: __00.05__ (05.11.2024)|
58
59
|[XXX-005: Consider hash-based integrity verification of byte code files against their source code files](CWE-664/XXX-005/.)||
|[CWE-78: Improper Neutralization of Special Elements Used in an OS Command ("OS Command Injection")](CWE-707/CWE-78/README.md)|[CVE-2024-43804](https://www.cvedetails.com/cve/CVE-2024-43804/),<br/>CVSSv3.1: **8.8**,<br/>EPSS: **00.06** (08.11.2024)|
91
-
|[CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')](CWE-707/CWE-89/README.md)|[CVE-2019-8600](https://www.cvedetails.com/cve/CVE-2019-8600/),<br/>CVSSv3.1: **9.8**,<br/>EPSS: **01.43** (18.02.2024)|
91
+
|[CWE-78: Improper Neutralization of Special Elements Used in an OS Command ("OS Command Injection")](CWE-707/CWE-78/README.md)|[CVE-2024-43804](https://www.cvedetails.com/cve/CVE-2024-43804/),<br/>CVSSv3.1: __8.8__,<br/>EPSS: __00.06__ (08.11.2024)|
92
+
|[CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')](CWE-707/CWE-89/README.md)|[CVE-2019-8600](https://www.cvedetails.com/cve/CVE-2019-8600/),<br/>CVSSv3.1: __9.8__,<br/>EPSS: __01.43__ (18.02.2024)|
92
93
|[CWE-117: Improper Output Neutralization for Logs](CWE-707/CWE-117/.)||
93
94
|[CWE-175: Improper Handling of Mixed Encoding](CWE-707/CWE-175/README.md)||
94
95
|[CWE-180: Incorrect behavior order: Validate before Canonicalize](CWE-707/CWE-180/.)||
@@ -102,11 +103,11 @@ It is **not production code** and requires code-style or python best practices t
|[OWASP 2022]|[OWASP Top 10 Report 2022](https://owasp.org/www-project-top-ten/)|
109
-
|[MITRE 2023]|[CWE Top 25 2022](https://cwe.mitre.org/top25/archive/2022/2022_cwe_top25.html)|
106
+
|[Python 2023]|3.9 Module Index[online], available from [https://docs.python.org/3.9/py-modindex.html](https://docs.python.org/3.9/py-modindex.html)[accessed Dec 2024]|
107
+
|[mitre.org 2023]|CWE - CWE-1000: Research Concepts[online], available from [https://cwe.mitre.org/data/definitions/1000.html](https://cwe.mitre.org/data/definitions/1000.html)[accessed Dec 2024]|
108
+
|[OWASP dev 2024]|OWASP Developer Guide[online], available from [https://owasp.org/www-project-developer-guide/release/](https://owasp.org/www-project-developer-guide/release/)[accessed Dec 2024]|
109
+
|[OWASP 2021]|OWASP Top 10 Report 2021 [online], available from [https://owasp.org/www-project-top-ten/](https://owasp.org/www-project-top-ten/)|
110
+
|[MITRE 2024]|CWE Top 25 [online], available form [https://cwe.mitre.org/top25/index.html](https://cwe.mitre.org/top25/archive/2022/2022_cwe_top25.html)[accessed Dec 2024]|
0 commit comments