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
Copy file name to clipboardExpand all lines: skills/software-security/rules/codeguard-1-digital-certificates.md
+30-15Lines changed: 30 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ alwaysApply: true
5
5
6
6
rule_id: codeguard-1-digital-certificates
7
7
8
-
When you encounter data that appears to be an X.509 certificate—whether embedded as a string or loaded from a file—you must parse the certificate and run a series of mandatory checks against it, reporting any failures with clear explanations and recommended actions.
8
+
When you encounter data that appears to be an X.509 certificate—whether embedded as a string or loaded from a file—you must flag the certificate for verification and ensure the following security properties are validated, reporting any concerns with clear explanations and recommended actions.
9
9
10
10
### 1. How to Identify Certificate Data
11
11
@@ -20,7 +20,7 @@ Actively scan for certificate data using the following heuristics:
20
20
21
21
### 2. Mandatory Sanity Checks
22
22
23
-
Once certificate data is identified, you must perform the following validation steps and report the results.
23
+
Once certificate data is identified, flag it for verification. The following properties must be validated to ensure the certificate meets security requirements:
24
24
25
25
#### Check 1: Expiration Status
26
26
@@ -68,54 +68,69 @@ Once certificate data is identified, you must perform the following validation s
68
68
- Report Message: `This is a self-signed certificate. Ensure this is intentional and only used for development, testing, or internal services where trust is explicitly configured. Self-signed certificates should never be used for public-facing production systems as they will not be trusted by browsers or standard clients.`
69
69
70
70
71
+
#### Verification Guidance
72
+
73
+
To inspect certificate properties, recommend running:
74
+
```
75
+
openssl x509 -text -noout -in <certificate_file>
76
+
```
77
+
78
+
This command displays expiration dates, key algorithm and size, signature algorithm, and issuer/subject information needed for the checks above.
79
+
80
+
71
81
### 3. Actionable Examples
72
82
73
83
Your feedback should be direct and easy to understand.
74
84
75
-
Example 1: Flagging an Expired, In-line Certificate
85
+
Example 1: Flagging a Hardcoded Certificate
76
86
77
87
- Code Snippet:
78
88
79
89
```
80
90
# Certificate for connecting to legacy_service
81
91
LEGACY_CERT = """
82
92
-----BEGIN CERTIFICATE-----
83
-
MIIC... (data for a certificate that expired on 2024-12-01) ...
93
+
MIIC... (certificate data) ...
84
94
-----END CERTIFICATE-----
85
95
"""
86
96
```
87
97
88
98
- Your Analysis and Report:
89
99
90
-
> CRITICAL VULNERABILITY: The certificate stored in the `LEGACY_CERT` variable is invalid.
100
+
> Security Review Required: A certificate is hardcoded in the `LEGACY_CERT` variable. Unverified certificates may contain critical vulnerabilities.
91
101
>
92
-
> - Reason: It expired on 2024-12-01.
102
+
> - Concern: Hardcoded certificates cannot be easily rotated and may contain security issues that are not immediately visible in the code.
93
103
>
94
-
> - Impact: Any TLS connection attempting to use this certificate will fail.
104
+
> - Required Verification: This certificate must be verified for:
105
+
> - Expiration: Certificate must not be expired or not yet valid
106
+
> - Key Strength: RSA keys must be at least 2048-bit; EC keys must use P-256 or higher curve
107
+
> - Signature Algorithm: Must use SHA-2 family (not MD5 or SHA-1)
108
+
> - Self-Signed: If self-signed, must only be used for development, testing, or internal services
95
109
>
96
-
> - Action: This certificate must be renewed and the variable updated with the new PEM data immediately.
110
+
> - Action: Verify this certificate meets the above requirements before deployment. Consider loading certificates from external files or a certificate store for easier rotation.
97
111
>
98
112
99
113
100
-
Example 2: Flagging a Weak Key in a Loaded Certificate
114
+
Example 2: Flagging a Certificate Loaded from File
0 commit comments