Closed Bug 1998526 Opened 1 year ago Closed 7 months ago

PKCS7 decoder context digest algorithms can go out-of-sync with digest array

Categories

(NSS :: Libraries, defect, P2)

Tracking

(nss 3.123, firefox-esr115 wontfix, firefox-esr140 wontfix, firefox149 wontfix, firefox150 wontfix, firefox151 fixed)

RESOLVED FIXED
Tracking Status
nss --- 3.123
firefox-esr115 --- wontfix
firefox-esr140 --- wontfix
firefox149 --- wontfix
firefox150 --- wontfix
firefox151 --- fixed

People

(Reporter: keeler, Assigned: djackson)

References

Details

(Keywords: sec-moderate, Whiteboard: [adv-main151+r])

Attachments

(1 external file, 1 obsolete file)

SEC_PKCS7SignedData has SECAlgorithmID **digestAlgorithms; and SECItem **digests;. The former is intended to describe each algorithm that created the latter. sec_pkcs7_decoder_start_digests has this code[0]:

    /*
     * Create a digest context for each algorithm.
     */
    for (i = 0; i < digcnt; i++) {
        SECAlgorithmID *algid = digestalgs[i];
        SECOidTag oidTag = SECOID_FindOIDTag(&(algid->algorithm));
        const SECHashObject *digobj = HASH_GetHashObjectByOidTag(oidTag);
        void *digcx;

        /*
         * Skip any algorithm we do not even recognize; obviously,
         * this could be a problem, but if it is critical then the
         * result will just be that the signature does not verify.
         * We do not necessarily want to error out here, because
         * the particular algorithm may not actually be important,
         * but we cannot know that until later.
         */
        if (digobj == NULL) {
            p7dcx->worker.digcnt--;
            continue;
        }

The wildly incorrect line p7dcx->worker.digcnt--; is being removed in bug 1964722, but even so, this can result in digests being shorter than (and in general not matching up with) digestAlgorithms, which can probably cause problems.

[0] https://searchfox.org/nss/rev/cd2ce1a24014a9afaff0df7b484f6065d845de7a/lib/pkcs7/p7decode.c#262-282

Group: core-security
Severity: -- → S3
Priority: -- → P1
Severity: S3 → S2

I've made it an S2 conservatively.

I believe the only way to reach this in Firefox is to manually import a client certificate.

Priority: P1 → P2
Duplicate of this bug: 2018939
Assignee: nobody → djackson
Status: NEW → ASSIGNED
Attached file (secure) —
Attached file (secure) (obsolete) —
Duplicate of this bug: 2030103

Pushed by djackson@mozilla.com:
https://hg.mozilla.org/projects/nss/rev/f03be1025fb2
Align PKCS7 digest array with digestAlgorithms r=nss-reviewers,rrelyea

Status: ASSIGNED → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED

Will land tests later on

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Group: crypto-core-security → core-security-release
Blocks: 2032562

Comment on attachment 9563863 [details]
(secure)

Revision D291857 was moved to bug 2032562. Setting attachment 9563863 [details] to obsolete.

Attachment #9563863 - Attachment is obsolete: true

Tests will land in Bug 2032562.

Status: REOPENED → RESOLVED
Closed: 7 months ago → 7 months ago
Resolution: --- → FIXED
QA Whiteboard: [sec] [qa-triage-done-c152/b151]
Whiteboard: [adv-main151+r]
Duplicate of this bug: 2029698
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: