Skip to content

Validate to/from parameters when remounting a backend#9890

Merged
vishalnayak merged 3 commits into
hashicorp:masterfrom
mdgreenfield:remount-param-validation
Oct 29, 2020
Merged

Validate to/from parameters when remounting a backend#9890
vishalnayak merged 3 commits into
hashicorp:masterfrom
mdgreenfield:remount-param-validation

Conversation

@mdgreenfield
Copy link
Copy Markdown
Contributor

@mdgreenfield mdgreenfield commented Sep 4, 2020

Vault uses http.ServeMux which issues an HTTP 301 redirect if the
request path contains a double slash (//). Additionally, vault
handles all paths to ensure that the path only contains printable
characters. Therefore use the same validation on the to/from parameters
for remounting.

Not doing this can result in a Vault mount that was originally mounted
at pki/foo to being remounted at pki/foo//bar resulting in mounts
that cannot be accessed.

fixes #9889

/cc @byxorna @ianferguson

Vault uses http.ServeMux which issues an HTTP 301 redirect if the
request path contains a double slash (`//`). Additionally, vault
handles all paths to ensure that the path only contains printable
characters. Therefore use the same validation on the to/from parameters
for remounting.

Not doing this can result in a Vault mount that was originally mounted
at `pki/foo` to being remounted at `pki/foo//bar` resulting in mounts
that cannot be accessed.
Comment thread vault/logical_system.go
Comment on lines +1048 to +1050
if err = validateMountPath(toPath); err != nil {
return handleError(fmt.Errorf("'to' %v", err))
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that I did not validate the fromPath because if we validate it then any Vault users would not be able to move their mounts back to the original name. Also, because the fromPath is the path that was already cleaned by http.ServeMux and the non-printable characters handler, fromPath should only ever be a valid path when a mount is created.

@briankassouf briankassouf added this to the 1.6 milestone Sep 11, 2020
@briankassouf briankassouf self-assigned this Sep 11, 2020
@briankassouf briankassouf removed their assignment Oct 28, 2020
Copy link
Copy Markdown
Contributor

@vishalnayak vishalnayak left a comment

Choose a reason for hiding this comment

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

Thanks for submitting the PR!

Comment thread vault/logical_system.go
@vishalnayak vishalnayak merged commit 363b546 into hashicorp:master Oct 29, 2020
@mdgreenfield mdgreenfield deleted the remount-param-validation branch October 29, 2020 18:12
@vishalnayak vishalnayak mentioned this pull request Oct 29, 2020
pull Bot pushed a commit to NOUIY/vault that referenced this pull request Oct 10, 2025
…hicorp#10049)

* move request to parent

* add changelog

* add test

* use refresh instead()

Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
tsaarni pushed a commit to Nordix/vault that referenced this pull request Oct 23, 2025
…hicorp#10050) (hashicorp#10071)

* move request to parent

* add changelog

* add test

* use refresh instead()

Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
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.

Unable to delete vault mount due to HTTP 301 redirect

3 participants