Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/27001.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:security
job: Disallow tasks using the name "alloc" which breaks inter-task filesystem isolation
```
6 changes: 6 additions & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8113,6 +8113,12 @@ func (t *Task) Validate(jobType string, tg *TaskGroup) error {
if t.Name == "" {
mErr.Errors = append(mErr.Errors, errors.New("Missing task name"))
}

// Tasks cannot be named "alloc" as this conflicts with and breaks task
// filesystem isolation features.
if t.Name == "alloc" {
mErr.Errors = append(mErr.Errors, errors.New("Task cannot be named \"alloc\""))
}
if strings.ContainsAny(t.Name, `/\`) {
// We enforce this so that when creating the directory on disk it will
// not have any slashes.
Expand Down
4 changes: 4 additions & 0 deletions nomad/structs/structs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2237,6 +2237,10 @@ func TestTask_Validate(t *testing.T) {
"task level: distinct_hosts",
"task level: distinct_property",
)

// Ensure the task name "alloc" is invalid.
invalidAllocName := &Task{Name: "alloc"}
must.ErrorContains(t, invalidAllocName.Validate(JobTypeBatch, tg), "Task cannot be named")
}

func TestTask_Validate_Resources(t *testing.T) {
Expand Down