CVE-2026-49838: Github.com/osrg/gobgp/v4 GoBGP Confederation Validation Panics On Vulnerability

MODERATE
Advisory Identifier: GHSA-frrj-87jh-2772
CVSS 5.9
CWE-129
Published
Advisory Summary

CVE-2026-49838 is a MODERATE (CVSS 5.9) gobgp confederation validation panics on vulnerability (CWE-129: Improper Validation of Array Index) affecting Github.com/osrg/gobgp/v4 libraries in the Go ecosystem. The issue involves gobgp confederation validation panics on empty as_path attribute. Remediation is available by upgrading affected packages to version 4.7.0.

CVE-2026-49838 at a Glance

CVE Identifier CVE-2026-49838
GHSA Identifier GHSA-frrj-87jh-2772
Severity MODERATE
CVSS v3.1 Base Score 5.9
CWE Classification CWE-129: Improper Validation of Array Index
Affected Product Github.com/osrg/gobgp/v4
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 5.9

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2026-49838

To remediate this vulnerability, upgrade all affected Github.com/osrg/gobgp/v4 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/osrg/gobgp/v4 fixed: 4.7.0
Upgrade github.com/osrg/gobgp/v4 to 4.7.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/osrg/gobgp/v4

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-49838, inspect your project dependencies for Github.com/osrg/gobgp/v4:

inspect dependencies for github.com/osrg/gobgp/v4

Analyze the terminal output to locate any version of Github.com/osrg/gobgp/v4 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.7.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-129: Improper Validation of Array Index, where the product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array. In Github.com/osrg/gobgp/v4, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Found through variant analysis based on `CVE-2026-41643` ## Summary GoBGP accepts a zero-length AS_PATH during UPDATE decoding and later panics while validating that attribute for a confederation eBGP peer. The vulnerable path is in the BGP UPDATE validator: a malformed UPDATE that should be rejected as a malformed AS_PATH instead reaches an unchecked `p.Value[0]` access, allowing a configured confederation eBGP peer to trigger a denial of service. ## Affected - Project: gobgp - Repo: https://github.com/osrg/gobgp - Pinned ref: c24629411ba49f160d9dc09126f418218127e016 ## Root cause An established peer's receive path reads BGP bytes from the network connection in `pkg/server/fsm.go:1267`, parses UPDATE bodies through the BGP message decoder, and validates decoded UPDATEs with peer state at `pkg/server/fsm.go:1849`. The UPDATE decoder walks the path-attribute list in `pkg/packet/bgp/bgp.go:15773` and selects the concrete attribute parser from the attacker-controlled attribute type at `pkg/packet/bgp/bgp.go:15855`. For AS_PATH, `PathAttributeAsPath.DecodeFromBytes` returns nil when the decoded attribute length is zero (`pkg/packet/bgp/bgp.go:11533`, `pkg/packet/bgp/bgp.go:11538`), leaving `p.Value` empty rather than reporting a malformed attribute. Validation then dispatches each decoded attribute through `ValidateAttribute` (`pkg/packet/bgp/validate.go:34`); in the confederation eBGP branch, `pkg/packet/bgp/validate.go:162` indexes `p.Value[0]` before checking that any AS_PATH segment was decoded. The eBGP and confederation guards are normal peer-state gates: `pkg/config/oc/util.go:127` defines eBGP as peer AS differing from local AS, `pkg/config/oc/util.go:116` checks confederation membership, and `pkg/server/fsm.go:740` and `pkg/server/fsm.go:741` copy those results into the FSM state used by the validator. ## Reproduction [INT-bgp-gobgp-confed-empty-aspath-panic.zip](https://github.com/user-attachments/files/28203698/INT-bgp-gobgp-confed-empty-aspath-panic.zip) ```bash bash ./poc/run.sh ``` ```text TRIGGERED: confed empty AS_PATH validation panic: runtime error: index out of range ``` The `TRIGGERED` line is the recovered panic fingerprint from the confederation eBGP validation path after a zero-length AS_PATH has decoded successfully. A build failure or any output without that fingerprint would not demonstrate this bug, because the signal is tied to the unchecked AS_PATH segment access. ## Impact A remote unauthenticated peer that is configured as a confederation eBGP neighbor can establish a BGP session and send a single malformed UPDATE containing a syntactically valid AS_PATH attribute header with zero value length. Because the decode path does not turn that empty AS_PATH into a `MessageError`, normal malformed-attribute handling is bypassed and validation panics before GoBGP can return a BGP NOTIFICATION. The demonstrated effect is denial of service for the receive goroutine and peer session, with potential process termination if the panic is not recovered by the runtime path; no memory corruption, data disclosure, authentication bypass, or code execution is claimed. ## Suggested fix ```001-fix.diff diff --git a/pkg/packet/bgp/validate.go b/pkg/packet/bgp/validate.go index 2237afb..f07f4fa 100644 --- a/pkg/packet/bgp/validate.go +++ b/pkg/packet/bgp/validate.go @@ -159,6 +159,9 @@ func ValidateAttribute(a PathAttributeInterface, rfs map[Family]BGPAddPathMode, case *PathAttributeAsPath: if isEBGP { if isConfed { + if len(p.Value) == 0 { + return false, NewMessageError(eCode, eSubCodeMalformedAspath, nil, "empty AS_PATH for confederation eBGP") + } if segType := p.Value[0].GetType(); segType != BGP_ASPATH_ATTR_TYPE_CONFED_SEQ { return false, NewMessageError(eCode, eSubCodeMalformedAspath, nil, fmt.Sprintf("segment type is not confederation seq (%d)", segType)) } ``` ## Resources - https://github.com/osrg/gobgp/blob/c24629411ba49f160d9dc09126f418218127e016/pkg/packet/bgp/bgp.go#L11533-L11540 - https://github.com/osrg/gobgp/blob/c24629411ba49f160d9dc09126f418218127e016/pkg/packet/bgp/validate.go#L159-L164

CVE-2026-49838 Affected Github.com/osrg/gobgp/v4 Versions

1 component(s)
Fixed Versions:
4.7.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/osrg/gobgp/v4
Go
< 4.7.0
4.7.0

References

Frequently Asked Questions

What is CVE-2026-49838?
CVE-2026-49838 is a security vulnerability in Github.com/osrg/gobgp/v4 involving GoBGP confederation validation panics on empty AS_PATH attribute under CWE-129: Improper Validation of Array Index.
Which Github.com/osrg/gobgp/v4 versions are affected?
Affected versions include releases prior to 4.7.0 across affected packages: github.com/osrg/gobgp/v4.
What version fixes CVE-2026-49838?
Upgrading to 4.7.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/osrg/gobgp/v4 affected?
Yes, github.com/osrg/gobgp/v4 is affected in releases prior to 4.7.0. Upgrade your dependency to 4.7.0 or later.
What is the CVSS score of CVE-2026-49838?
CVE-2026-49838 has a CVSS v3.1 base score of 5.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-49838?
CVE-2026-49838 is classified under CWE-129: Improper Validation of Array Index (The product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array.).
How can I check Go dependencies for CVE-2026-49838?
Run the dependency tree command: 'inspect dependencies for github.com/osrg/gobgp/v4'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-frrj-87jh-2772",
  "modified" : "2026-07-09T23:21:05Z",
  "published" : "2026-07-09T23:21:05Z",
  "aliases" : [ "CVE-2026-49838" ],
  "summary" : "GoBGP confederation validation panics on empty AS_PATH attribute",
  "details" : "Found through variant analysis based on `CVE-2026-41643`\n\n## Summary\nGoBGP accepts a zero-length AS_PATH during UPDATE decoding and later panics while validating that attribute for a confederation eBGP peer. The vulnerable path is in the BGP UPDATE validator: a malformed UPDATE that should be rejected as a malformed AS_PATH instead reaches an unchecked `p.Value[0]` access, allowing a configured confederation eBGP peer to trigger a denial of service.\n\n## Affected\n- Project: gobgp\n- Repo: https://github.com/osrg/gobgp\n- Pinned ref: c24629411ba49f160d9dc09126f418218127e016\n\n## Root cause\nAn established peer's receive path reads BGP bytes from the network connection in `pkg/server/fsm.go:1267`, parses UPDATE bodies through the BGP message decoder, and validates decoded UPDATEs with peer state at `pkg/server/fsm.go:1849`. The UPDATE decoder walks the path-attribute list in `pkg/packet/bgp/bgp.go:15773` and selects the concrete attribute parser from the attacker-controlled attribute type at `pkg/packet/bgp/bgp.go:15855`. For AS_PATH, `PathAttributeAsPath.DecodeFromBytes` returns nil when the decoded attribute length is zero (`pkg/packet/bgp/bgp.go:11533`, `pkg/packet/bgp/bgp.go:11538`), leaving `p.Value` empty rather than reporting a malformed attribute. Validation then dispatches each decoded attribute through `ValidateAttribute` (`pkg/packet/bgp/validate.go:34`); in the confederation eBGP branch, `pkg/packet/bgp/validate.go:162` indexes `p.Value[0]` before checking that any AS_PATH segment was decoded. The eBGP and confederation guards are normal peer-state gates: `pkg/config/oc/util.go:127` defines eBGP as peer AS differing from local AS, `pkg/config/oc/util.go:116` checks confederation membership, and `pkg/server/fsm.go:740` and `pkg/server/fsm.go:741` copy those results into the FSM state used by the validator.\n\n## Reproduction\n\n[INT-bgp-gobgp-confed-empty-aspath-panic.zip](https://github.com/user-attachments/files/28203698/INT-bgp-gobgp-confed-empty-aspath-panic.zip)\n\n```bash\nbash ./poc/run.sh\n```\n\n```text\nTRIGGERED: confed empty AS_PATH validation panic: runtime error: index out of range\n```\n\nThe `TRIGGERED` line is the recovered panic fingerprint from the confederation eBGP validation path after a zero-length AS_PATH has decoded successfully. A build failure or any output without that fingerprint would not demonstrate this bug, because the signal is tied to the unchecked AS_PATH segment access.\n\n## Impact\nA remote unauthenticated peer that is configured as a confederation eBGP neighbor can establish a BGP session and send a single malformed UPDATE containing a syntactically valid AS_PATH attribute header with zero value length. Because the decode path does not turn that empty AS_PATH into a `MessageError`, normal malformed-attribute handling is bypassed and validation panics before GoBGP can return a BGP NOTIFICATION. The demonstrated effect is denial of service for the receive goroutine and peer session, with potential process termination if the panic is not recovered by the runtime path; no memory corruption, data disclosure, authentication bypass, or code execution is claimed.\n\n## Suggested fix\n```001-fix.diff\ndiff --git a/pkg/packet/bgp/validate.go b/pkg/packet/bgp/validate.go\nindex 2237afb..f07f4fa 100644\n--- a/pkg/packet/bgp/validate.go\n+++ b/pkg/packet/bgp/validate.go\n@@ -159,6 +159,9 @@ func ValidateAttribute(a PathAttributeInterface, rfs map[Family]BGPAddPathMode,\n \tcase *PathAttributeAsPath:\n \t\tif isEBGP {\n \t\t\tif isConfed {\n+\t\t\t\tif len(p.Value) == 0 {\n+\t\t\t\t\treturn false, NewMessageError(eCode, eSubCodeMalformedAspath, nil, \"empty AS_PATH for confederation eBGP\")\n+\t\t\t\t}\n \t\t\t\tif segType := p.Value[0].GetType(); segType != BGP_ASPATH_ATTR_TYPE_CONFED_SEQ {\n \t\t\t\t\treturn false, NewMessageError(eCode, eSubCodeMalformedAspath, nil, fmt.Sprintf(\"segment type is not confederation seq (%d)\", segType))\n \t\t\t\t}\n```\n\n## Resources\n- https://github.com/osrg/gobgp/blob/c24629411ba49f160d9dc09126f418218127e016/pkg/packet/bgp/bgp.go#L11533-L11540\n- https://github.com/osrg/gobgp/blob/c24629411ba49f160d9dc09126f418218127e016/pkg/packet/bgp/validate.go#L159-L164",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/osrg/gobgp/v4"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.7.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.6.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/osrg/gobgp/security/advisories/GHSA-frrj-87jh-2772"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/osrg/gobgp"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-129" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-09T23:21:05Z",
    "nvd_published_at" : null
  }
}