Skip to content

eigrpd: fix byte order in Hello authentication decode - #21545

Merged
donaldsharp merged 1 commit into
FRRouting:masterfrom
TristanInSec:fix/eigrp-hello-auth-byteorder
Apr 17, 2026
Merged

eigrpd: fix byte order in Hello authentication decode#21545
donaldsharp merged 1 commit into
FRRouting:masterfrom
TristanInSec:fix/eigrp-hello-auth-byteorder

Conversation

@TristanInSec

Copy link
Copy Markdown

eigrp_hello_authentication_decode() compares md5->auth_type and md5->length directly against host-order constants, but these struct fields are stored in network byte order (the send path uses htons() at eigrp_packet.c:1248). On little-endian hosts the comparisons never match, so authentication is silently skipped.

Wrap both fields with ntohs() to match the encoding.

Signed-off-by: Tristan Madani tristan@live.fr

@greptile-apps

greptile-apps Bot commented Apr 15, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a network byte order bug in eigrp_hello_authentication_decode(): the auth_type and length fields of received TLV structs are in network byte order (the send path uses htons() at eigrp_packet.c:1248), but were compared directly against host-order constants. On little-endian hosts this caused all authenticated EIGRP hello packets to be silently dropped.

The fix β€” wrapping both fields with ntohs() β€” is minimal and correct. Note that eigrp_hello_parameter_decode() (line 110) and eigrp_sw_version_decode() (line 221) have the same pattern (tlv->length < sizeof(...) without ntohs()), which are pre-existing bugs not addressed here.

Confidence Score: 5/5

Safe to merge β€” the fix is minimal, correct, and directly mirrors the encoding used in the send path.

The change is a four-line, mechanical byte-order correction with no logic complexity. The ntohs() calls match the htons() in eigrp_add_authTLV_MD5_to_stream / eigrp_add_authTLV_SHA256_to_stream. No new code paths or data structures are introduced. All remaining notes are about pre-existing issues outside the diff.

No files require special attention; the only changed file applies the fix correctly.

Important Files Changed

Filename Overview
eigrpd/eigrp_hello.c Adds ntohs() around md5->auth_type and md5->length in eigrp_hello_authentication_decode() β€” correct fix matching the htons() encoding in the send path.

Sequence Diagram

sequenceDiagram
    participant Wire as Network Wire
    participant Recv as eigrp_hello_receive
    participant Decode as eigrp_hello_authentication_decode
    participant Check as eigrp_check_md5_digest

    Wire->>Recv: Hello packet (fields in network byte order)
    Recv->>Recv: ntohs(tlv_header->type) β†’ EIGRP_TLV_AUTH
    Recv->>Decode: pass raw tlv_header pointer
    Note over Decode: BEFORE fix: auth_type compared without ntohs,<br/>always fails on little-endian hosts
    Note over Decode: AFTER fix: ntohs(md5->auth_type) == EIGRP_AUTH_TYPE_MD5
    Note over Decode: AFTER fix: ntohs(md5->length) validates TLV size
    alt auth type matches and length valid
        Decode->>Check: eigrp_check_md5_digest or eigrp_check_sha256_digest
        Check-->>Decode: pass or fail result
        Decode-->>Recv: result (1 = ok, 0 = drop)
    else no match
        Decode-->>Recv: 0 drop packet
    end
    Recv->>Recv: if 0 return early, else continue
Loading

Reviews (1): Last reviewed commit: "eigrpd: fix byte order in Hello authenti..." | Re-trigger Greptile

@mjstapp mjstapp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the greptile review notes another couple of places that may have the same issue: can you add those to the PR?

@github-actions github-actions Bot added size/S and removed size/XS labels Apr 15, 2026
@TristanInSec

Copy link
Copy Markdown
Author

Good catch. Added ntohs() to the parameter, software version, and peer termination decode functions in the latest push.

@mjstapp

mjstapp commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

ah: please rebase and squash/fixup the second commit into the first, no need to have two commits there (and the commit-format checker is flagging it anyway)

@mjstapp mjstapp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks good, thanks (still need the commit fixes before merging)

The auth_type and length fields in EIGRP Hello TLV structures are
network byte order, but several decode functions compare them against
host-order constants without ntohs().

Add ntohs() to all affected comparisons:
- eigrp_hello_authentication_decode: auth_type and length checks
- eigrp_hello_parameter_decode: length check
- eigrp_sw_version_decode: length check
- eigrp_peer_termination_decode: length check

Signed-off-by: Tristan Madani <tristan@live.fr>
@TristanInSec
TristanInSec force-pushed the fix/eigrp-hello-auth-byteorder branch from 90c7935 to b8e6379 Compare April 16, 2026 16:29
@donaldsharp

Copy link
Copy Markdown
Member

@Mergifyio backport stable/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2 stable/10.1 stable/10.0

@mergify

mergify Bot commented Apr 17, 2026

Copy link
Copy Markdown

backport stable/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2 stable/10.1 stable/10.0

βœ… Backports have been created

Details

@donaldsharp
donaldsharp merged commit 9ef27ad into FRRouting:master Apr 17, 2026
31 of 32 checks passed
donaldsharp added a commit that referenced this pull request Apr 17, 2026
eigrpd: fix byte order in Hello authentication decode (backport #21545)
donaldsharp added a commit that referenced this pull request Apr 17, 2026
eigrpd: fix byte order in Hello authentication decode (backport #21545)
donaldsharp added a commit that referenced this pull request Apr 17, 2026
eigrpd: fix byte order in Hello authentication decode (backport #21545)
donaldsharp added a commit that referenced this pull request Apr 17, 2026
eigrpd: fix byte order in Hello authentication decode (backport #21545)
donaldsharp added a commit that referenced this pull request Apr 17, 2026
eigrpd: fix byte order in Hello authentication decode (backport #21545)
donaldsharp added a commit that referenced this pull request Apr 17, 2026
eigrpd: fix byte order in Hello authentication decode (backport #21545)
donaldsharp added a commit that referenced this pull request Apr 17, 2026
eigrpd: fix byte order in Hello authentication decode (backport #21545)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants