[PR #193] fix: reject a negative length argument in <r>/<rc>/<rd>/<dz> tags #198

Open
opened 2026-10-13 21:04:30 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amneziawg-go/pull/193
Author: @artromone
Created: 9/3/2026
Status: 🔄 Open

Base: master ← Head: fix/reject-negative-obf-tag-length


📝 Commits (1)

  • 9710d69 fix: reject a negative length argument in /// tags

📊 Changes

6 files changed (+58 additions, -9 deletions)

View changed files

📝 device/obf.go (+15 -0)
📝 device/obf_datasize.go (+1 -3)
📝 device/obf_rand.go (+1 -2)
📝 device/obf_randchars.go (+1 -2)
📝 device/obf_randdigits.go (+1 -2)
➕ device/obf_test.go (+39 -0)

📄 Description

The four length-taking CPS tags parse their argument with strconv.Atoi and store it unchecked, so a negative N in i1-i5 is accepted by set= without error. The value then flows through ObfuscatedLen into make([]byte, ...) and dst[:N], and the daemon panics on the next handshake send with "makeslice: len out of range".

Add parseObfLen and use it in the four builders, so the config is refused at parse time with a message naming the offending tag. Zero stays legal — it simply contributes nothing to the packet.

This only rules out negatives. Whether these lengths should also have an upper bound is a separate policy question and is left alone here.

Refs #189


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/amnezia-vpn/amneziawg-go/pull/193 **Author:** [@artromone](https://github.com/artromone) **Created:** 9/3/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix/reject-negative-obf-tag-length` --- ### 📝 Commits (1) - [`9710d69`](https://github.com/amnezia-vpn/amneziawg-go/commit/9710d6948d317705e189b7d002e5c65a85796880) fix: reject a negative length argument in <r>/<rc>/<rd>/<dz> tags ### 📊 Changes **6 files changed** (+58 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `device/obf.go` (+15 -0) 📝 `device/obf_datasize.go` (+1 -3) 📝 `device/obf_rand.go` (+1 -2) 📝 `device/obf_randchars.go` (+1 -2) 📝 `device/obf_randdigits.go` (+1 -2) ➕ `device/obf_test.go` (+39 -0) </details> ### 📄 Description The four length-taking CPS tags parse their argument with strconv.Atoi and store it unchecked, so a negative N in i1-i5 is accepted by set= without error. The value then flows through ObfuscatedLen into make([]byte, ...) and dst[:N], and the daemon panics on the next handshake send with "makeslice: len out of range". Add parseObfLen and use it in the four builders, so the config is refused at parse time with a message naming the offending tag. Zero stays legal — it simply contributes nothing to the packet. This only rules out negatives. Whether these lengths should also have an upper bound is a separate policy question and is left alone here. Refs #189 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amneziawg-go#198
No description provided.