Closed Bug 2072682 Opened 15 days ago Closed 15 days ago

Use PORT_ReleaseAssert to guard changes to refcounts which may lead to UAF

Categories

(NSS :: Libraries, enhancement, P3)

enhancement

Tracking

(nss 3.130)

RESOLVED FIXED
Tracking Status
nss --- 3.130

People

(Reporter: djackson, Assigned: djackson)

Details

Attachments

(9 files)

D325339 introduces PORT_ReleaseAssert`. We should guard any ref counts with suitable invariants. Examples:

  • SEC_DestroyCrl
  • CERT_DestroyGeneralNameList
  • tls13_ReleaseAntiReplayContext
  • pk11_getKeyFromList
  • sftk_FreeSession & sftk_DestroySession
  • PK11_FreeSlot & PK11_ReferenceSlot
  • SECMOD_DestroyModule & SECMOD_ReferenceModule
  • nssPKIObject_Destroy & nssPKIObject_AddRef
  • PK11_FreeSlotListElement
  • ssl_FreeKeyPair

The CMS layer consumes the reference returned by
NSSCMSGetDecryptKeyCallback, so returning the caller's borrowed pointer
over-released the bulk key: cmsutil -C destroyed it while the content
info still held it, and the release assert in PK11_FreeSymKey caught the
subsequent double free. Release cmsutil's own reference once, in the
common cleanup, so the -D and batch paths are balanced too.

Both CRLs allocated with PORT_ArenaZNew were released at a reference
count of zero, which the old SEC_DestroyCrl condition silently accepted.

Assignee: nobody → djackson

Pushed by djackson@mozilla.com:
https://hg.mozilla.org/projects/nss/rev/94285024c0eb
abort on detected key object double frees r=nss-reviewers,jschanck
https://hg.mozilla.org/projects/nss/rev/8a643df1bd5c
free never-live symkeys directly in pk11_getKeyFromList r=nss-reviewers,keeler
https://hg.mozilla.org/projects/nss/rev/97401b74aaec
release-assert CRL and GeneralNameList reference counts r=nss-reviewers,keeler
https://hg.mozilla.org/projects/nss/rev/889ed0cdd65f
release-assert SSL reference counts r=nss-reviewers,keeler
https://hg.mozilla.org/projects/nss/rev/8c204d8b9571
release-assert pk11wrap slot, module and symkey reference counts r=nss-reviewers,keeler
https://hg.mozilla.org/projects/nss/rev/f1a3e216d616
release-assert stan object reference counts r=nss-reviewers,keeler
https://hg.mozilla.org/projects/nss/rev/2704de033b19
release-assert softoken session and db reference counts r=nss-reviewers,keeler
https://hg.mozilla.org/projects/nss/rev/c282985dcde6
take a reference in cmsutil's CMS decrypt-key callback r=nss-reviewers,keeler
https://hg.mozilla.org/projects/nss/rev/5d33f08ca5fb
initialize referenceCount in crlutil's CRL allocations r=nss-reviewers,keeler

Status: NEW → RESOLVED
Closed: 15 days ago
Resolution: --- → FIXED
status-nss: --- → 3.130
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: