Bug 312411

Summary: Fix leaks from Security APIs by using adoptCF() for CFErrorRef out parameters
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: WebKit Misc.Assignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

David Kilzer (:ddkilzer)
Reported 2026-04-15 13:48:36 PDT
Several Security framework APIs (`SecTrustSerialize`, `SecTrustDeserialize`, `SecTrustCopyPropertyListRepresentation`, `SecTrustCreateFromPropertyListRepresentation`, `SecKeyCreateRandomKey`, `SecKeyCreateWithData`) return +1 retained `CFErrorRef` objects through their out parameters, but the APIs are missing the `CF_RETURNS_RETAINED` annotation on those parameters (rdar://161546781). Newer functions in the same headers (`SecTrustCopyTrustStoreContentDigest`, `SecTrustGetAssetVersionNumber`, etc.) already have the annotation, but these older APIs have not been updated. WebKit callers store the raw `CFErrorRef` in a local variable, check it for errors, but never release it -- leaking the error object on every error path. This affects both production code (`CoreIPCSecTrust.mm`, `WKRemoteObjectCoder.mm`, `VirtualAuthenticatorUtils.mm`) and test code (`IPCSerialization.mm`, `Challenge.mm`, `WebTransport.mm`, `_WKWebAuthenticationPanel.mm`, `TestControllerCocoa.mm`).
Attachments
Radar WebKit Bug Importer
Comment 1 2026-04-15 13:52:08 PDT
David Kilzer (:ddkilzer)
Comment 2 2026-04-15 16:46:39 PDT
EWS
Comment 3 2026-04-17 08:35:25 PDT
Committed 311454@main (12b5e059d376): <https://commits.webkit.org/311454@main> Reviewed commits have been landed. Closing PR #62860 and removing active labels.
EWS
Comment 4 2026-04-29 21:33:57 PDT
Committed 305413.773@safari-7624-branch (ffded96c95cd): <https://commits.webkit.org/305413.773@safari-7624-branch> Reviewed commits have been landed. Closing PR #5126 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.