Skip to content

Commit 09ce72f

Browse files
author
Michael Smith
committed
deps: @sigstore/core@4.0.1
1 parent a18679a commit 09ce72f

5 files changed

Lines changed: 74 additions & 26 deletions

File tree

node_modules/pacote/node_modules/@sigstore/core/dist/asn1/length.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,23 @@ function decodeLength(stream) {
3737
// Iterate over the bytes that encode the length.
3838
let len = 0;
3939
for (let i = 0; i < byteCount; i++) {
40-
len = len * 256 + stream.getUint8();
40+
const byte = stream.getUint8();
41+
// The first byte of a multi-byte length must not be zero; a leading zero
42+
// means the length could have been encoded in fewer bytes (non-minimal).
43+
if (i === 0 && byte === 0x00) {
44+
throw new error_1.ASN1ParseError('non-minimal length encoding');
45+
}
46+
len = len * 256 + byte;
4147
}
4248
// This is a valid ASN.1 length encoding, but we don't support it.
4349
if (len === 0) {
4450
throw new error_1.ASN1ParseError('indefinite length encoding not supported');
4551
}
52+
// Lengths less than 128 must use the short form; rejecting them here ensures
53+
// the encoding is minimal (strict DER).
54+
if (len < 128) {
55+
throw new error_1.ASN1ParseError('non-minimal length encoding');
56+
}
4657
return len;
4758
}
4859
// Translates the supplied value to a DER-encoded length.

node_modules/pacote/node_modules/@sigstore/core/dist/asn1/obj.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ class ASN1Obj {
3232
}
3333
// Constructs an ASN.1 object from a Buffer of DER-encoded bytes.
3434
static parseBuffer(buf) {
35-
return parseStream(new stream_1.ByteStream(buf));
35+
const stream = new stream_1.ByteStream(buf);
36+
const obj = parseStream(stream);
37+
// Ensure the entire buffer was consumed; trailing data after the top-level
38+
// object indicates a malformed (or maliciously padded) encoding.
39+
if (stream.position !== stream.length) {
40+
throw new error_1.ASN1ParseError('invalid trailing data');
41+
}
42+
return obj;
3643
}
3744
toDER() {
3845
const valueStream = new stream_1.ByteStream();
@@ -103,7 +110,14 @@ class ASN1Obj {
103110
exports.ASN1Obj = ASN1Obj;
104111
/////////////////////////////////////////////////////////////////////////////
105112
// Internal stream parsing functions
106-
function parseStream(stream) {
113+
// Maximum nesting depth for parsed ASN.1 objects. Bounds the mutual recursion
114+
// between parseStream and collectSubs so that deeply nested DER cannot exhaust
115+
// the call stack (denial of service).
116+
const MAX_DEPTH = 100;
117+
function parseStream(stream, depth = 0) {
118+
if (depth > MAX_DEPTH) {
119+
throw new error_1.ASN1ParseError('maximum nesting depth exceeded');
120+
}
107121
// Parse tag, length, and value from stream
108122
const tag = new tag_1.ASN1Tag(stream.getUint8());
109123
const len = (0, length_1.decodeLength)(stream);
@@ -114,13 +128,17 @@ function parseStream(stream) {
114128
// are embedded in OCTESTRING objects, so we need to check those
115129
// for children as well.
116130
if (tag.constructed) {
117-
subs = collectSubs(stream, len);
131+
subs = collectSubs(stream, len, depth);
118132
}
119133
else if (tag.isOctetString()) {
120134
// Attempt to parse children of OCTETSTRING objects. If anything fails,
121-
// assume the object is not constructed and treat as primitive.
135+
// assume the object is not constructed and treat as primitive. This is
136+
// intentional: it transparently unwraps DER content embedded in an OCTET
137+
// STRING (e.g. X.509 extnValue, CMS eContent). The error is swallowed
138+
// because a parse failure simply means the bytes are an opaque primitive
139+
// value rather than a nested structure.
122140
try {
123-
subs = collectSubs(stream, len);
141+
subs = collectSubs(stream, len, depth);
124142
}
125143
catch (e) {
126144
// Fail silently and treat as primitive
@@ -132,7 +150,7 @@ function parseStream(stream) {
132150
}
133151
return new ASN1Obj(tag, value, subs);
134152
}
135-
function collectSubs(stream, len) {
153+
function collectSubs(stream, len, depth) {
136154
// Calculate end of object content
137155
const end = stream.position + len;
138156
// Make sure there are enough bytes left in the stream. This should never
@@ -145,7 +163,7 @@ function collectSubs(stream, len) {
145163
// Parse all children
146164
const subs = [];
147165
while (stream.position < end) {
148-
subs.push(parseStream(stream));
166+
subs.push(parseStream(stream, depth + 1));
149167
}
150168
// When we're done parsing children, we should be at the end of the object
151169
if (stream.position !== end) {

node_modules/pacote/node_modules/@sigstore/core/dist/asn1/parse.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2121
See the License for the specific language governing permissions and
2222
limitations under the License.
2323
*/
24+
const error_1 = require("./error");
2425
const RE_TIME_SHORT_YEAR = /^(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\.\d{3})?Z$/;
2526
const RE_TIME_LONG_YEAR = /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\.\d{3})?Z$/;
2627
// Parse a BigInt from the DER-encoded buffer
@@ -83,30 +84,48 @@ function parseOID(buf) {
8384
const first = Math.floor(n / 40);
8485
const second = n % 40;
8586
let oid = `${first}.${second}`;
86-
// Consume remaining bytes
87-
let val = 0;
87+
// Consume remaining bytes. Use a BigInt accumulator so that arcs which
88+
// exceed 32 bits are not silently truncated (a truncated arc could be made
89+
// to collide with a trusted OID).
90+
let val = 0n;
8891
for (; pos < end; ++pos) {
8992
n = buf[pos];
90-
val = (val << 7) + (n & 0x7f);
93+
val = (val << 7n) + BigInt(n & 0x7f);
9194
// If the left-most bit is NOT set, then this is the last byte in the
9295
// sequence and we can add the value to the OID and reset the accumulator
9396
if ((n & 0x80) === 0) {
9497
oid += `.${val}`;
95-
val = 0;
98+
val = 0n;
9699
}
97100
}
98101
return oid;
99102
}
100103
// Parse a boolean from the DER-encoded buffer
101104
// https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-basic-types#boolean
102105
function parseBoolean(buf) {
103-
return buf[0] !== 0;
106+
// DER requires a BOOLEAN to be a single byte that is either 0x00 (false) or
107+
// 0xff (true). Reject any other (non-canonical) encoding.
108+
if (buf.length !== 1) {
109+
throw new error_1.ASN1ParseError('invalid boolean');
110+
}
111+
switch (buf[0]) {
112+
case 0x00:
113+
return false;
114+
case 0xff:
115+
return true;
116+
default:
117+
throw new error_1.ASN1ParseError('invalid boolean');
118+
}
104119
}
105120
// Parse a bit string from the DER-encoded buffer
106121
// https://learn.microsoft.com/en-us/windows/win32/seccertenroll/about-bit-string
107122
function parseBitString(buf) {
108123
// First byte tell us how many unused bits are in the last byte
109124
const unused = buf[0];
125+
// The number of unused bits must be in the range 0-7.
126+
if (unused > 7) {
127+
throw new error_1.ASN1ParseError('invalid bit string');
128+
}
110129
const start = 1;
111130
const end = buf.length;
112131
const bits = [];

node_modules/pacote/node_modules/@sigstore/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sigstore/core",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"description": "Base library for Sigstore",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

package-lock.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10552,9 +10552,9 @@
1055210552
}
1055310553
},
1055410554
"node_modules/pacote/node_modules/@sigstore/core": {
10555-
"version": "4.0.0",
10556-
"resolved": "https://registry.npmjs.org/@sigstore/core/-/core-4.0.0.tgz",
10557-
"integrity": "sha512-uFGJpKiMCKXV+61jsxQ0ECfr0wjDP+8qnT6pgfsOXbIk0j/KPfBSp2Dks/YcNcT/S4e3P267JKPL6gAwygJRuw==",
10555+
"version": "4.0.1",
10556+
"resolved": "https://registry.npmjs.org/@sigstore/core/-/core-4.0.1.tgz",
10557+
"integrity": "sha512-9v5hRjujn5NXq8o7XFEUgLyAtdr5Iisb4pzM05u3K61IS5q3hP3luWAndk0RkPPLTUFoTbg7Vb84UQ1ZQeajWQ==",
1055810558
"inBundle": true,
1055910559
"license": "Apache-2.0",
1056010560
"engines": {
@@ -16356,6 +16356,15 @@
1635616356
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
1635716357
}
1635816358
},
16359+
"workspaces/libnpmpublish/node_modules/@sigstore/core": {
16360+
"version": "4.0.1",
16361+
"resolved": "https://registry.npmjs.org/@sigstore/core/-/core-4.0.1.tgz",
16362+
"integrity": "sha512-9v5hRjujn5NXq8o7XFEUgLyAtdr5Iisb4pzM05u3K61IS5q3hP3luWAndk0RkPPLTUFoTbg7Vb84UQ1ZQeajWQ==",
16363+
"license": "Apache-2.0",
16364+
"engines": {
16365+
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
16366+
}
16367+
},
1635916368
"workspaces/libnpmpublish/node_modules/sigstore": {
1636016369
"version": "5.0.0",
1636116370
"resolved": "https://registry.npmjs.org/sigstore/-/sigstore-5.0.0.tgz",
@@ -16385,15 +16394,6 @@
1638516394
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
1638616395
}
1638716396
},
16388-
"workspaces/libnpmpublish/node_modules/sigstore/node_modules/@sigstore/core": {
16389-
"version": "4.0.0",
16390-
"resolved": "https://registry.npmjs.org/@sigstore/core/-/core-4.0.0.tgz",
16391-
"integrity": "sha512-uFGJpKiMCKXV+61jsxQ0ECfr0wjDP+8qnT6pgfsOXbIk0j/KPfBSp2Dks/YcNcT/S4e3P267JKPL6gAwygJRuw==",
16392-
"license": "Apache-2.0",
16393-
"engines": {
16394-
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
16395-
}
16396-
},
1639716397
"workspaces/libnpmpublish/node_modules/sigstore/node_modules/@sigstore/sign": {
1639816398
"version": "5.0.0",
1639916399
"resolved": "https://registry.npmjs.org/@sigstore/sign/-/sign-5.0.0.tgz",

0 commit comments

Comments
 (0)