Skip to content

Commit 818cbba

Browse files
committed
Drop device category field and fix integration issues
Removed device-category from the CDDL schema, addressed review comments, and fixed test failures. Updated docs and examples to match. Signed-off-by: Alex Tzonkov <4975715+attzonko@users.noreply.github.com>
1 parent 981cbff commit 818cbba

18 files changed

Lines changed: 903 additions & 283 deletions

Documentation/corim_profile/OCP-SAFE-CoRIM-Extension-Profile-Specification.md

Lines changed: 96 additions & 111 deletions
Large diffs are not rendered by default.

Documentation/corim_profile/examples/ocp-safe-sfr-fw-example.diag

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,27 @@
6868
}
6969
}
7070
],
71-
/ 5: device-category / 5: 0, / 0: storage, 1: network, 2: gpu, 3: cpu, 4: apu, 5: bmc /
72-
/ 6: issues / 6: [
71+
/ 5: issues / 5: [
7372
/ issue-entry / {
74-
/ 0: title / 0: "Memory corruption when reading record from SPI flash",
75-
/ 1: cvss-score / 1: "7.9",
76-
/ 2: cvss-vector / 2: "AV:L/AC:L/PR:L/UI:N/S:C/C:L/I:H/A:L",
77-
/ 3: cwe / 3: "CWE-111",
78-
/ 4: description / 4: "Due to insufficient input validation in the firmware, a local attacker who tampers with a configuration structure in SPI flash, can cause stack-based memory corruption.",
79-
/ 5: cvss-version / 5: "3.1"
73+
/ 0: title / 0: "Memory corruption when reading record from SPI flash",
74+
/ 1: description / 1: "Due to insufficient input validation in the firmware, a local attacker who tampers with a configuration structure in SPI flash, can cause stack-based memory corruption.",
75+
/ 2: assessment / 2: {
76+
/ 0: cvss-score / 0: "7.9",
77+
/ 1: cvss-vector / 1: "AV:L/AC:L/PR:L/UI:N/S:C/C:L/I:H/A:L",
78+
/ 2: cvss-version / 2: "3.1"
79+
},
80+
/ 3: cwe / 3: "CWE-111"
8081
},
8182
/ issue-entry / {
82-
/ 0: title / 0: "Debug commands enable arbitrary memory read/write",
83-
/ 1: cvss-score / 1: "8.7",
84-
/ 2: cvss-vector / 2: "AV:L/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:L",
85-
/ 3: cwe / 3: "CWE-222",
86-
/ 4: description / 4: "The firmware exposes debug command handlers that enable host-side drivers to read and write arbitrary regions of the device's SRAM.",
87-
/ 5: cvss-version / 5: "3.1",
88-
/ 6: cve / 6: "CVE-2014-10000"
83+
/ 0: title / 0: "Debug commands enable arbitrary memory read/write",
84+
/ 1: description / 1: "The firmware exposes debug command handlers that enable host-side drivers to read and write arbitrary regions of the device's SRAM.",
85+
/ 2: assessment / 2: {
86+
/ 0: cvss-score / 0: "8.7",
87+
/ 1: cvss-vector / 1: "AV:L/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:L",
88+
/ 2: cvss-version / 2: "3.1"
89+
},
90+
/ 3: cwe / 3: "CWE-222",
91+
/ 4: cve / 4: "CVE-2014-10000"
8992
}
9093
]
9194
}

Documentation/corim_profile/ocp-safe-sfr-profile.cddl

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,28 @@ ocp-safe-sfr-map = {
1010
&(report-version: 1) => tstr
1111
&(completion-date: 2) => time
1212
&(scope-number: 3) => integer
13-
&(fw-identifiers: 4) => [ + fw-identifier ]
14-
? &(device-category: 5) => $device-category
15-
? &(issues: 6) => [ + issue-entry ]
13+
? &(fw-identifiers: 4) => [ + fw-identifier ]
14+
? &(issues: 5) => [ + issue-entry ]
1615
* $$ocp-safe-sfr-map-ext
1716
}
1817

1918
issue-entry = {
2019
&(title: 0) => tstr
21-
&(cvss-score: 1) => tstr
22-
&(cvss-vector: 2) => tstr
23-
&(cwe: 3) => tstr
24-
&(description: 4) => tstr
25-
? &(cvss-version: 5) => tstr
26-
? &(cve: 6) => tstr
20+
&(description: 1) => tstr
21+
&(assessment: 2) => $assessment
22+
?&(cwe: 3) => tstr
23+
?&(cve: 4) => tstr
2724
* $$ocp-safe-issue-entry-ext
2825
}
2926

27+
$assessment /= cvss
28+
29+
cvss = {
30+
&(score: 0) => tstr
31+
&(vector: 1) => tstr
32+
&(version: 2) => tstr
33+
}
34+
3035
fw-identifier = non-empty<{
3136
? &(fw-version: 0) => version-map
3237
? &(fw-file-digests: 1) => digests-type
@@ -42,18 +47,4 @@ manifest-entry = {
4247
src-manifest = {
4348
&(manifest-digest: 0) => digests-type
4449
&(manifest: 1) => [ + manifest-entry ]
45-
}
46-
47-
$device-category /= storage
48-
$device-category /= network
49-
$device-category /= gpu
50-
$device-category /= cpu
51-
$device-category /= apu
52-
$device-category /= bmc
53-
54-
storage = 0
55-
network = 1
56-
gpu = 2
57-
cpu = 3
58-
apu = 4
59-
bmc = 5
50+
}

shortform_report-main/AUDITOR_GUIDE.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ The most important section for auditors shows the actual security review finding
5858
🔸 Field 2: Completion Date
5959
🔸 Field 3: Scope Number
6060
🔸 Field 4: Firmware Identifiers
61-
🔸 Field 5: Device Category
62-
🔸 Field 6: Issues - List of security issues found
61+
🔸 Field 5: Issues - List of security issues found
6362
```
6463

6564
### 4. Security Issues Detail
@@ -90,7 +89,6 @@ When reviewing a CoRIM file, verify the following:
9089
- [ ] SFR extension (-1) is present in measurement values
9190
- [ ] All required SFR fields are present (0-6)
9291
- [ ] Completion date is properly encoded with CBOR timestamp tag
93-
- [ ] Device category is a valid integer (0-5)
9492
- [ ] Framework version matches expected value
9593

9694
### ✅ Security Issues Validation
@@ -132,17 +130,6 @@ When reviewing a CoRIM file, verify the following:
132130
```
133131
**Solution**: Check that all mandatory CoRIM fields are included during generation.
134132

135-
## Device Category Reference
136-
137-
The tool automatically translates device category numbers:
138-
139-
- **0**: CPU (Central Processing Unit)
140-
- **1**: GPU (Graphics Processing Unit)
141-
- **2**: BMC (Baseboard Management Controller)
142-
- **3**: NIC (Network Interface Controller)
143-
- **4**: Storage (Storage devices)
144-
- **5**: Other (Other device types)
145-
146133
## CBOR Tag Reference
147134

148135
Common CBOR tags you'll see in the output:

shortform_report-main/OcpReportLib.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@
6767
4096, # RSA 512
6868
)
6969

70-
# CoRIM specific constants
71-
DEVICE_CATEGORIES = {"storage": 0, "network": 1, "gpu": 2, "cpu": 3, "apu": 4, "bmc": 5}
72-
7370
# CBOR tags for CoRIM
7471
CORIM_TAG = 501
7572
COMID_TAG = 506
@@ -162,8 +159,9 @@ def add_device(
162159
163160
vendor: The name of the vendor that manufactured the device.
164161
product: The name of the device. Usually a model name or number.
165-
category: The type of device that was audited. Usually a short string
166-
such as: 'storage', 'network', 'gpu', 'cpu', 'apu', or 'bmc'.
162+
category: [LEGACY] The type of device (e.g., 'storage', 'network', 'gpu').
163+
This field is included for backward compatibility with the JSON schema
164+
but is NOT included in CoRIM output as it's not part of the CDDL spec.
167165
repo_tag: The Git repository tag associated with the audit. Useful when
168166
evaluating ROMs for which we cannot easily calculate or
169167
verify the hash.
@@ -339,14 +337,6 @@ def _convert_to_corim_structure(self) -> Dict[str, Any]:
339337

340338
fw_identifiers.append(fw_id)
341339

342-
# Convert device category to integer
343-
category_str = self.report["device"]["category"].lower()
344-
device_category = None
345-
for cat, val in DEVICE_CATEGORIES.items():
346-
if cat in category_str:
347-
device_category = val
348-
break
349-
350340
# Convert issues
351341
corim_issues = []
352342
for issue in self.report["audit"]["issues"]:
@@ -378,11 +368,8 @@ def _convert_to_corim_structure(self) -> Dict[str, Any]:
378368
4: fw_identifiers, # fw-identifiers
379369
}
380370

381-
if device_category is not None:
382-
sfr_map[5] = device_category # device-category
383-
384371
if corim_issues:
385-
sfr_map[6] = corim_issues # issues
372+
sfr_map[5] = corim_issues # issues
386373

387374
return sfr_map
388375

shortform_report-main/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ What follows is an example JSON payload for a hypothetical review of a typical b
8181
"device": {
8282
"vendor": "ACME Inc",
8383
"product": "Roadrunner Trap",
84-
"category": "storage",
8584
"repo_tag": "release_v1_2_3",
8685
"fw_version": "1.2.3",
8786
"fw_hash_sha2_384": "0xcd484defa77e8c3e4a8dd73926e32365ea0dbd01e4eff017f211d4629cfcd8e4890dd66ab1bded9be865cd1c849800d4",
@@ -123,7 +122,6 @@ This second example is an example JSON payload for a small SDK source code packa
123122
"device": {
124123
"vendor": "ACME Inc",
125124
"product": "Roadrunner Trap",
126-
"category": "storage",
127125
"repo_tag": "release_v1_2_3",
128126
"fw_version": "1.2.3",
129127
"fw_hash_sha2_384": "848aff556097fc1eaf08253abd00af0aad0c317c3490e88bef09348658ce6e14829815fca075d9e03fcf236a47ff91dc",
@@ -192,7 +190,6 @@ A collection of fields that describe the vendor, device, and firmware version th
192190

193191
* `vendor`: The name of the vendor that manufactured the device or firmware being tested.
194192
* `product`: The name of the device. Usually a model name of number.
195-
* `category`: The type of device that was audited. Usually a short string such as: `storage`, `network`, `gpu`, `cpu`, `apu`, or `bmc`.
196193
* `repo_tag`: If applicable, the report can include the repository tag for the code that was audited. This may also be useful for ROM audits where the OCP Member is unable to verify the firmware hash.
197194
* `fw_version`: The version of the firmware image that is attested by the signed short-form report. In most cases this will be the firmware version compiled by the vendor after the security audit completes, which contains fixes for all vulnerabilities that were found during the audit.
198195
* `fw_hash_sha2_384`: A hex-encoded string containing the SHA2-384 hash of the firmware image. If the `manifest` field is present, it is a hash of that field instead.
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# Human-Readable CBOR CoRIM Inspector
2+
3+
## Overview
4+
5+
This directory contains tools for generating and inspecting CBOR-encoded CoRIM (CBOR Object Representation of Information Model) files in a human-readable format. These tools are specifically designed for security auditors and reviewers who need to visually verify the contents of binary CBOR files.
6+
7+
## Files in This Package
8+
9+
### Core Tools
10+
11+
- **`cbor_human_inspector.py`** - Main human-readable CBOR inspector tool
12+
- **`test_human_inspector.py`** - Test script that generates sample CoRIM and demonstrates the inspector
13+
- **`AUDITOR_GUIDE.md`** - Comprehensive guide for auditors on how to use these tools
14+
15+
### Supporting Files
16+
17+
- **`OcpReportLib.py`** - Library for generating Security Review Reports in CoRIM format
18+
- **`tests/final_validation_summary.py`** - Comprehensive CDDL compliance validation
19+
- **`tests/cbor_structure_analyzer.py`** - Technical CBOR structure analysis
20+
21+
## Quick Start
22+
23+
### 1. Generate and Inspect a Test CoRIM
24+
25+
```bash
26+
# Generate a sample CoRIM file and inspect it
27+
python test_human_inspector.py
28+
```
29+
30+
This will:
31+
- Create a sample security review report
32+
- Convert it to CoRIM format
33+
- Encode it as CBOR
34+
- Display a human-readable analysis
35+
36+
### 2. Inspect an Existing CoRIM File
37+
38+
```bash
39+
# Basic inspection
40+
python cbor_human_inspector.py your_corim_file.cbor
41+
42+
# Include raw CBOR data
43+
python cbor_human_inspector.py your_corim_file.cbor --show-raw
44+
```
45+
46+
## Key Features
47+
48+
### 🔍 Human-Readable Analysis
49+
- Converts binary CBOR to clear, structured text
50+
- Explains the purpose of each field
51+
- Shows field names instead of just numbers
52+
- Provides context for CBOR tags and data types
53+
54+
### ✅ Validation Indicators
55+
- Visual checkmarks (✅) for correct structures
56+
- Warning symbols (❌) for issues or missing data
57+
- Clear explanations of what each validation means
58+
59+
### 📊 Detailed Content Display
60+
- Security issues with CVSS scores, CWE identifiers, and descriptions
61+
- Firmware information including hashes and versions
62+
- Timestamp formatting and validation
63+
64+
### 🎯 Auditor-Focused Output
65+
- Structured for systematic review
66+
- Highlights critical security information
67+
- Provides validation checklists
68+
- Supports audit trail documentation
69+
70+
## Example Output
71+
72+
```
73+
================================================================================
74+
CBOR CoRIM Human-Readable Inspector
75+
================================================================================
76+
📊 Total CBOR size: 1286 bytes
77+
🔍 Analysis timestamp: 2025-01-15 14:30:22
78+
79+
------------------------------------------------------------
80+
Top-Level Structure Analysis
81+
------------------------------------------------------------
82+
✅ CBOR Tag Found: 501 (CoRIM (CBOR Object Representation of Information Model))
83+
✅ This is a valid CoRIM structure
84+
✅ CoRIM contains 4 top-level fields
85+
86+
🔸 Field 3: Profile - Identifies the CoRIM profile being used
87+
✅ Proper OID tag (111)
88+
🆔 Profile: 1.3.6.1.4.1.42623.1.1 (OCP SAFE SFR Profile)
89+
90+
🔐 SFR Extension (-1) Found!
91+
📋 SFR Data contains 7 fields:
92+
93+
🔸 Field 6: Issues - List of security issues found during review
94+
🚨 3 security issue(s) found:
95+
96+
🔴 Issue #1:
97+
Title: Buffer Overflow in Firmware Parser
98+
CVSS Score: 9.1
99+
CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
100+
CWE: CWE-787
101+
Description: A critical buffer overflow vulnerability...
102+
CVE: CVE-2025-0123
103+
```
104+
105+
## Use Cases
106+
107+
### For Security Auditors
108+
- **Verify CoRIM Structure**: Ensure all required fields are present and correctly formatted
109+
- **Review Security Issues**: Examine reported vulnerabilities in detail
110+
- **Validate Compliance**: Check that CoRIMs follow OCP SAFE SFR profile specifications
111+
- **Create Audit Reports**: Generate human-readable documentation for audit trails
112+
113+
### For Security Review Providers
114+
- **Quality Assurance**: Verify that generated CoRIMs contain expected data
115+
- **Debugging**: Identify issues in CoRIM generation processes
116+
- **Client Communication**: Provide clear explanations of CoRIM contents
117+
118+
### For Framework Developers
119+
- **Testing**: Validate CoRIM generation and encoding
120+
- **Debugging**: Analyze CBOR structure issues
121+
- **Documentation**: Create examples and demonstrations
122+
123+
## Integration with OCP SAFE Framework
124+
125+
This tool is specifically designed for the OCP Security SAFE (Security Assurance Framework for Ecosystems) and supports:
126+
127+
- **OCP SAFE SFR Profile**: OID 1.3.6.1.4.1.42623.1.1
128+
- **Private Extension (-1)**: For OCP SAFE SFR data
129+
- **CDDL Schema Compliance**: Validates against the OCP SAFE SFR CDDL profile
130+
- **Security Review Reports**: Structured security assessment data
131+
132+
## Technical Details
133+
134+
### Supported CBOR Features
135+
- CBOR tags (timestamps, OIDs, CoRIM, COMID)
136+
- Nested CBOR structures
137+
- Binary data formatting
138+
- Dictionary and array structures
139+
140+
### Validation Capabilities
141+
- Required field presence checking
142+
- Data type validation
143+
- CBOR tag verification
144+
- OID format validation
145+
- Timestamp encoding verification
146+
147+
### Output Formats
148+
- Structured text with Unicode symbols
149+
- Hierarchical indentation
150+
- Color-coded status indicators (when terminal supports it)
151+
- Raw CBOR hex dump (optional)
152+
153+
## Dependencies
154+
155+
- `cbor2` - CBOR encoding/decoding
156+
- `datetime` - Timestamp handling
157+
- Standard Python libraries
158+
159+
## Error Handling
160+
161+
The tool provides clear error messages for common issues:
162+
- Invalid CBOR files
163+
- Missing required fields
164+
- Incorrect data types
165+
- Malformed structures
166+
167+
## Contributing
168+
169+
When extending this tool:
170+
1. Maintain the human-readable focus
171+
2. Add clear explanations for new fields
172+
3. Include validation logic for new structures
173+
4. Update the auditor guide with new features
174+
175+
## License
176+
177+
This tool is part of the OCP Security SAFE framework and follows the same licensing terms.

0 commit comments

Comments
 (0)