forked from microsoft/azurelinux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCVE-2025-12816.patch
More file actions
122 lines (118 loc) · 5.12 KB
/
CVE-2025-12816.patch
File metadata and controls
122 lines (118 loc) · 5.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
From a05dd812ec2de46ece35a11ab4b46c9d283d1505 Mon Sep 17 00:00:00 2001
From: Vijay Sarvepalli <vssarvepalli@cert.org>
Date: Thu, 6 Nov 2025 22:05:19 -0500
Subject: [PATCH] Fix for vulnerbaility CVE-2025-12816
Upstream Patch Reference: https://app.codecov.io/gh/digitalbazaar/forge/commit/a5ce91d03df4dcfc025b74a5b7f50389942d49c9?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=digitalbazaar
PR link: https://github.com/digitalbazaar/forge/pull/1124
---
src/ui/node_modules/node-forge/lib/asn1.js | 72 ++++++++++++++++----
src/ui/node_modules/node-forge/lib/pkcs12.js | 3 +
2 files changed, 61 insertions(+), 14 deletions(-)
diff --git a/src/ui/node_modules/node-forge/lib/asn1.js b/src/ui/node_modules/node-forge/lib/asn1.js
index e0fea0e0..53c77050 100644
--- a/src/ui/node_modules/node-forge/lib/asn1.js
+++ b/src/ui/node_modules/node-forge/lib/asn1.js
@@ -1148,22 +1148,65 @@ asn1.validate = function(obj, v, capture, errors) {
if(v.value && forge.util.isArray(v.value)) {
var j = 0;
for(var i = 0; rval && i < v.value.length; ++i) {
- rval = v.value[i].optional || false;
- if(obj.value[j]) {
- rval = asn1.validate(obj.value[j], v.value[i], capture, errors);
- if(rval) {
- ++j;
- } else if(v.value[i].optional) {
+ var schemaItem = v.value[i];
+ rval = !!schemaItem.optional;
+
+ // current child in the object
+ var objChild = obj.value[j];
+
+ // if there is no child left to match
+ if(!objChild) {
+ // if optional, ok (rval already true), else fail below
+ if(!schemaItem.optional) {
+ rval = false;
+ if(errors) {
+ errors.push('[' + v.name + '] ' +
+ 'Missing required element. Expected tag class "' +
+ schemaItem.tagClass + '", type "' + schemaItem.type + '"');
+ }
+ }
+ continue;
+ }
+
+ // If schema explicitly specifies tagClass/type, do a quick structural check
+ // to avoid unnecessary recursion/side-effects when tags clearly don't match.
+ var schemaHasTag = (typeof schemaItem.tagClass !== 'undefined' &&
+ typeof schemaItem.type !== 'undefined');
+
+ if(schemaHasTag &&
+ (objChild.tagClass !== schemaItem.tagClass || objChild.type !== schemaItem.type)) {
+ // Tags do not match.
+ if(schemaItem.optional) {
+ // Skip this schema element (don't consume objChild; don't call recursive validate).
rval = true;
+ continue;
+ } else {
+ // Required schema item mismatched - fail.
+ rval = false;
+ if(errors) {
+ errors.push('[' + v.name + '] ' +
+ 'Tag mismatch. Expected (' +
+ schemaItem.tagClass + ',' + schemaItem.type + '), got (' +
+ objChild.tagClass + ',' + objChild.type + ')');
+ }
+ break;
}
}
- if(!rval && errors) {
- errors.push(
- '[' + v.name + '] ' +
- 'Tag class "' + v.tagClass + '", type "' +
- v.type + '" expected value length "' +
- v.value.length + '", got "' +
- obj.value.length + '"');
+
+ // Tags are compatible (or schema did not declare tags) - dive into recursive validate.
+ var childRval = asn1.validate(objChild, schemaItem, capture, errors);
+ if(childRval) {
+ // consume this child
+ ++j;
+ rval = true;
+ } else if(schemaItem.optional) {
+ // validation failed but element is optional => skip schema item (don't consume child)
+ rval = true;
+ } else {
+ // required item failed
+ rval = false;
+ // errors should already be populated by recursive call; keep failing
+ break;
}
}
}
@@ -1209,7 +1252,8 @@ asn1.validate = function(obj, v, capture, errors) {
if(obj.type !== v.type) {
errors.push(
'[' + v.name + '] ' +
- 'Expected type "' + v.type + '", got "' + obj.type + '"');
+ 'Expected type "' + v.type + '", got "' +
+ obj.type + '"');
}
}
return rval;
diff --git a/src/ui/node_modules/node-forge/lib/pkcs12.js b/src/ui/node_modules/node-forge/lib/pkcs12.js
index cd06c494..dee8b36a 100644
--- a/src/ui/node_modules/node-forge/lib/pkcs12.js
+++ b/src/ui/node_modules/node-forge/lib/pkcs12.js
@@ -474,6 +474,9 @@ p12.pkcs12FromAsn1 = function(obj, strict, password) {
if(macValue.getBytes() !== capture.macDigest) {
throw new Error('PKCS#12 MAC could not be verified. Invalid password?');
}
+ } else if(Array.isArray(obj.value) && obj.value.length > 2) {
+ /* This is pfx data that should have mac and verify macDigest */
+ throw new Error('Invalid PKCS#12. macData field present but MAC was not validated.');
}
_decodeAuthenticatedSafe(pfx, data.value, strict, password);
--
2.43.0