Skip to content

Fix encode path hyphen - #384

Merged
chrisarcand merged 2 commits into
masterfrom
fix-encode-path-hyphen
Feb 3, 2026
Merged

Fix encode path hyphen#384
chrisarcand merged 2 commits into
masterfrom
fix-encode-path-hyphen

Conversation

@chrisarcand

@chrisarcand chrisarcand commented Feb 3, 2026

Copy link
Copy Markdown
Member

Fixes #350
Closes #343

The encode_path method in lib/vault/encode.rb incorrectly encodes the hyphen (-) character, causing 403 permission denied errors when accessing paths like /auth/token/lookup-self on modern Vault servers (1.15+).

Cause: The regex [^a-zA-Z0-9_.-/] has an unescaped hyphen inside the character class. In Ruby regex, an unescaped hyphen between characters defines a range (e.g., .-/ means "characters from . to /"), not the literal characters ., -, and /.

The hyphen gets URL-encoded to %2D, which newer Vault versions don't decode before checking permissions.

Cherry picked a PR'd solution to this with attribution, I just added some tests and changelog entries.

TaopaiC and others added 2 commits February 3, 2026 15:09
Fix `encode_path` whitelist to exclude '-' from encoding
- Add unit tests for EncodePath#encode_path verifying correct
  handling of hyphens, spaces, and special characters
- Document the encode_path hyphen fix in CHANGELOG [GH-350, GH-343]
@chrisarcand
chrisarcand requested a review from a team as a code owner February 3, 2026 21:18

@ryanuber ryanuber left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🚢

@chrisarcand
chrisarcand merged commit 4a8af15 into master Feb 3, 2026
27 of 28 checks passed
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.

Incorrect urlencoding causes permission denied errors

3 participants