Skip to content

Fix TypeError in verified-key cache eviction when cache exceeds MAXIMUM_CACHE_SIZE - #443

Open
buildwithakhila wants to merge 1 commit into
apple:mainfrom
buildwithakhila:fix/verified-key-cache-eviction-crash
Open

Fix TypeError in verified-key cache eviction when cache exceeds MAXIMUM_CACHE_SIZE#443
buildwithakhila wants to merge 1 commit into
apple:mainfrom
buildwithakhila:fix/verified-key-cache-eviction-crash

Conversation

@buildwithakhila

Copy link
Copy Markdown

SignedDataVerifier.verifyCertificateChain()'s cache-eviction loop iterates for (let key in Object.keys(this.verifiedPublicKeyCache)). Object.keys(...) returns an array, and for...in over an array yields the array's indices ("0", "1", ...), not the cache's own keys. So this.verifiedPublicKeyCache[key] was always undefined inside the loop, and .cacheExpiry threw a TypeError the moment the cache grew past MAXIMUM_CACHE_SIZE (32 entries) — which happens for any long-running server (with enableOnlineChecks: true) that verifies enough distinct certificate chains within the 15-minute cache window.

Fix: iterate the cache's keys directly with for...of Object.keys(...) instead of for...in Object.keys(...).

Added a regression test that seeds the cache past MAXIMUM_CACHE_SIZE with expired entries and verifies one more chain and it fails with the exact reported TypeError on the old code and passes with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant