Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipsec: Fix IPsec decrypt_esp for NAT-Traversal #4370

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ImanAfaneh293
Copy link

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

Copy link

codecov bot commented Apr 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.56%. Comparing base (8461c2e) to head (39218a1).
Report is 11 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 Coverage Δ
scapy/layers/ipsec.py 90.92% <100.00%> (+0.25%) ⬆️

... and 5 files with indirect coverage changes

@gpotter2
Copy link
Member

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

@gpotter2
Copy link
Member

gpotter2 commented May 1, 2024

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

@ImanAfaneh293
Copy link
Author

Thanks, sure will add a unit test

@ImanAfaneh293
Copy link
Author

@gpotter2 could you please review
thanks in advance

@gpotter2
Copy link
Member

gpotter2 commented May 12, 2024

Thanks. This test doesn't work though.

You should test it locally using

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

@ImanAfaneh293
Copy link
Author

I tested it locally and the test passed

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

Signed-off-by: Iman Afaneh <iafaneh@nvidia.com>
Signed-off-by: Iman Afaneh <iafaneh@nvidia.com>
@ImanAfaneh293
Copy link
Author

@gpotter2 could you please review
thanks in advance

1 similar comment
@ImanAfaneh293
Copy link
Author

@gpotter2 could you please review
thanks in advance

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.

None yet

2 participants