Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Low] CleanupSandboxState joins an unchecked id into paths it RemoveAll()s

Open Beginner friendly
#2,932 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
backend, security

Research direction

Read cmd/ateworker-microvm/internal/kata/cleanup_linux.go, starting at CleanupSandboxState and its os.RemoveAll calls. Add the suggested ID validation and unit tests for "", "." and ".."; done means invalid IDs cannot make cleanup target parent directories and the tests pass.

Written by the indexing model from the issue text.

Description

area/security kind/bug

Summary

kata.CleanupSandboxState builds /run/kata-containers/shared/sandboxes/<id> and <vcVMDir>/<id> with filepath.Join and later os.RemoveAlls them, without checking that id is non-empty and a single path element. Every current caller passes a UUID-validated actor UID, so this is defense in depth.

Details

cmd/ateworker-microvm/internal/kata/cleanup_linux.go#L50-L54:

func CleanupSandboxState(ctx context.Context, id string) {
	dirs := []string{
		filepath.Join("/run/kata-containers/shared/sandboxes", id),
		filepath.Join(vcVMDir, id),
	}

and #L96-L99:

if err := os.RemoveAll(d); err != nil {
	slog.WarnContext(ctx, "Failed to remove leftover sandbox dir",
		slog.String("dir", d), slog.Any("err", err))
}

With id == "" the targets are the parent directories themselves. With id == ".." they are their parents.

Impact

Low: not reachable today, because ateworkervalidation checks the actor UID at every ateworker-microvm RPC entry point (run.go, restore.go, checkpoint.go). A future caller that passes an unvalidated or empty ID would wipe the shared state of every sandbox on the node.

Suggested fix

At the top of CleanupSandboxState, return early (and log) unless id != "" && filepath.IsLocal(id) && filepath.Base(id) == id, or parse it as a UUID. Add a unit test for "", . and ...

Dominant language
Go
Stars
5.7k
Forks
612
Avg merge
2d 14h
Merged PRs (30d)
533

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from agent-substrate/substrate

All issues in agent-substrate/substrate

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.