scapy icon indicating copy to clipboard operation
scapy copied to clipboard

ipsec: Fix IPsec decrypt_esp for NAT-Traversal

Open ImanAfaneh293 opened this issue 1 year ago • 10 comments

When having nat_header, encrypted.underlayer will return UDP/ESP, so when decrypting IPv6 packet, the decrypt packet will be return with nat_header (UDP), which will return a corrupted packet.

Example:

original packet: IPv6/TCP/Raw encrypted packet: IPv6/UDP/ESP Decrypted packet: IPv6/UDP/TCP/Raw

ImanAfaneh293 avatar Apr 29 '24 14:04 ImanAfaneh293

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 81.56%. Comparing base (8461c2e) to head (39218a1). Report is 69 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4370      +/-   ##
==========================================
- Coverage   81.56%   81.56%   -0.01%     
==========================================
  Files         352      352              
  Lines       83897    83900       +3     
==========================================
- Hits        68431    68430       -1     
- Misses      15466    15470       +4     
Files with missing lines Coverage Δ
scapy/layers/ipsec.py 90.92% <100.00%> (+0.25%) :arrow_up:

... and 5 files with indirect coverage changes

codecov[bot] avatar Apr 29 '24 14:04 codecov[bot]

Please provide a unit test as an example of what your PR fixes.

gpotter2 avatar Apr 29 '24 18:04 gpotter2

Thanks for the PR ! it looks good, but could you please add a unit test ? Thanks

gpotter2 avatar May 01 '24 16:05 gpotter2

Thanks, sure will add a unit test

ImanAfaneh293 avatar May 08 '24 06:05 ImanAfaneh293

@gpotter2 could you please review thanks in advance

ImanAfaneh293 avatar May 08 '24 10:05 ImanAfaneh293

Thanks. This test doesn't work though.

You should test it locally using

./run_tests -t scapy/layers/ipsec.uts -F

gpotter2 avatar May 12 '24 21:05 gpotter2

I tested it locally and the test passed

ImanAfaneh293 avatar May 19 '24 10:05 ImanAfaneh293

@gpotter2 could you please review thanks in advance

ImanAfaneh293 avatar May 23 '24 06:05 ImanAfaneh293

@gpotter2 could you please review thanks in advance

ImanAfaneh293 avatar Jun 05 '24 06:06 ImanAfaneh293

@gpotter2 could you review Do you have any comments for this fix?

ImanAfaneh293 avatar Jul 24 '24 09:07 ImanAfaneh293

Really, terribly sorry for the delay, thanks a lot for the PR ! I finally took the time to test it and looks good.

gpotter2 avatar Sep 02 '24 19:09 gpotter2