The analysis of the security advisory and the associated commit 54469a95e5a20a8602ac1457b2110bfeb80c8891 confirms that the vulnerability lies within the gmrtd/gmrtd library's handling of file reads from NFC sources. The root cause of the CVE is the lack of input validation on the length field of BER-TLV encoded data in the ReadFile function. A malicious or non-compliant NFC device could specify a very large file length (up to 4GB), causing the ReadFile function to enter a resource-intensive loop, attempting to read an enormous file. This leads to excessive CPU and memory usage, resulting in a denial of service.
The primary vulnerable function is NfcSession.ReadFile located in iso7816/nfc_session.go. The patch directly addresses the vulnerability by introducing two key checks: one to enforce a maximum allowable TLV length (readFileMaxTlvLength) and another to limit the number of read iterations (readFileMaxChunks).
Additionally, the NfcSession.ReadBinaryFromOffset function, which is utilized by ReadFile, was also patched. This function now verifies that the data received from the transceiver does not exceed the requested length, providing an additional layer of defense against abnormal responses from the NFC source. Both functions would appear in a runtime profile during an exploit scenario.