-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
alloc fs: use case-insensitive check for reads of secret/private dir #24125
Merged
+80
−2
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:security | ||
security: Fixed a bug in client FS API where the check to prevent reads from the secrets dir could be bypassed on case-insensitive file systems | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
//go:build !linux | ||
// +build !linux | ||
|
||
package allocdir | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/hashicorp/nomad/ci" | ||
"github.com/hashicorp/nomad/helper/testlog" | ||
"github.com/hashicorp/nomad/nomad/structs" | ||
"github.com/hashicorp/nomad/plugins/drivers/fsisolation" | ||
"github.com/shoenig/test/must" | ||
) | ||
|
||
func TestAllocDir_ReadAt_CaseInsensitiveSecretDir(t *testing.T) { | ||
ci.Parallel(t) | ||
|
||
// On macOS, os.TempDir returns a symlinked path under /var which | ||
// is outside of the directories shared into the VM used for Docker. | ||
// Expand the symlink to get the real path in /private, which is ok. | ||
tmp, err := filepath.EvalSymlinks(t.TempDir()) | ||
must.NoError(t, err) | ||
|
||
d := NewAllocDir(testlog.HCLogger(t), tmp, tmp, "test") | ||
must.NoError(t, d.Build()) | ||
defer func() { _ = d.Destroy() }() | ||
|
||
td := d.NewTaskDir(t1Windows) | ||
must.NoError(t, td.Build(fsisolation.None, nil, "nobody")) | ||
|
||
target := filepath.Join(t1Windows.Name, TaskSecrets, "test_file") | ||
|
||
full := filepath.Join(d.AllocDir, target) | ||
must.NoError(t, os.WriteFile(full, []byte("hi"), 0o600)) | ||
|
||
targetCaseInsensitive := filepath.Join(t1Windows.Name, "sEcReTs", "test_file") | ||
|
||
_, err = d.ReadAt(targetCaseInsensitive, 0) | ||
must.EqError(t, err, "Reading secret file prohibited: "+targetCaseInsensitive) | ||
} | ||
|
||
var ( | ||
t1Windows = &structs.Task{ | ||
Name: "web", | ||
Driver: "exec", | ||
Config: map[string]interface{}{ | ||
"command": "/bin/date", | ||
"args": "+%s", | ||
}, | ||
Resources: &structs.Resources{ | ||
DiskMB: 1, | ||
}, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BSDs are gonna be sad, but we don't officially support them anyway. Perhaps:
(can we drop the old
// +build
way? it was replaced 3+ years ago)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, but we've got roughly a zillion of those so let's do it all in one big
sed
in its own PR. 😁