The descriptor cache records (WALLETDESCRIPTORCACHE/WALLETDESCRIPTORLHCACHE) deserialise their value into a vector whose length comes from the record itself, but CExtPubKey::Decode then reads a fixed BIP32_EXTKEY_SIZE bytes. A record encoding a shorter xpub makes Decode read past the vector (caught as a container-overflow under ASan).
The first commit rejects records whose serialised xpub isn't exactly BIP32_EXTKEY_SIZE, the same way the other malformed records in this loader return DBErrors::CORRUPT, with a unit test covering both cache types.
The second commit (per #35440 (comment)) replaces CExtKey/CExtPubKey Encode/Decode and EncodeWithVersion/DecodeWithVersion, the only (de)serialisation in the codebase that wrote into a caller-provided buffer, with Serialize/Unserialize, and routes the base58, PSBT and wallet cache code through them. The serialised bytes are unchanged, so base58 and PSBT encodings and the on-disk cache records are the same as before. The wallet loader now checks the record's CompactSize prefix and reads the xpub straight from the record stream.