P1sec / pycrate

A Python library to ease the development of encoders and decoders for various protocols and file formats; contains ASN.1 and CSN.1 compilers.
GNU Lesser General Public License v2.1
380 stars 130 forks source link

Unable to decode Delete PDP context request #240

Closed lubosve closed 1 year ago

lubosve commented 1 year ago

Hello, I have a problem decoding "Delete PDP context request" with TS29060_GTP.parse_GTP(). When attempting to do so, the parser will end up in infinite loop.

I have checked that set of parameters and their optional/mandatory status in GTP specification corresponds with your implementation: https://github.com/P1sec/pycrate/blob/47aaef8528d459e4df68a9854079c76679c7daec/pycrate_mobile/TS29060_GTP.py#L3137-L3163 https://www.etsi.org/deliver/etsi_ts/129000_129099/129060/17.04.00_60/ts_129060v170400p.pdf image

From wireshark I could see, that all the mandatory fields are filled in, I have also managed to decode the message with different decoder. I have also tried to decode different types of GTP messages with your decoder and I observed no difficulties.

Here are the data I am trying to decode: hex form: "3214001f0000500150670000130114059800080232f020004508ff9900024301d6000464914ffe" bin form: b'2\x14\x00\x1f\x00\x00P\x01Pg\x00\x00\x13\x01\x14\x05\x98\x00\x08\x022\xf0 \x00E\x08\xff\x99\x00\x02C\x01\xd6\x00\x04d\x91O\xfe'

Please, let me know if you need any further details. Thank you.

p1-bmu commented 1 year ago

Thanks for reporting, this was a bad bug. On the other side, I think the buffer is not perfectly correct as the last IE, which is a private extension, has not a valid length. Fix available in https://github.com/P1sec/pycrate/commit/6fd12f67ce44bfa5e8374447f5e4311f349082e6