Skip to content

feat(server): always disable /debug/pprof/cmdline, return 404#903

Merged
colega merged 3 commits intomainfrom
feat/disable-pprof-cmdline-by-default
Feb 13, 2026
Merged

feat(server): always disable /debug/pprof/cmdline, return 404#903
colega merged 3 commits intomainfrom
feat/disable-pprof-cmdline-by-default

Conversation

@colega
Copy link
Copy Markdown
Contributor

@colega colega commented Feb 12, 2026

The /debug/pprof/cmdline endpoint exposes the full command line of the running process, which may contain sensitive information such as credentials passed as flags. This unconditionally disables the endpoint by returning 404, with no configuration option to re-enable it.


Note

Low Risk
Small, localized change to debug routing plus a test; behavior change only impacts the pprof cmdline endpoint.

Overview
The server now unconditionally disables the /debug/pprof/cmdline endpoint by explicitly registering it to return 404, while leaving other /debug/pprof routes served from http.DefaultServeMux.

Adds a regression test (TestPprofCmdlineDisabled) asserting /debug/pprof/cmdline returns 404 and that other pprof endpoints like /debug/pprof/ and /debug/pprof/heap still return 200.

Written by Cursor Bugbot for commit 0508ab2. This will update automatically on new commits. Configure here.

Copy link
Copy Markdown
Contributor

@56quarters 56quarters left a comment

Choose a reason for hiding this comment

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

Why is cmdline special? Why would any of /debug be public?

@colega
Copy link
Copy Markdown
Contributor Author

colega commented Feb 12, 2026

None of /debug should be public, but shit happens. When shit happens, I'd rather have someone reporting that they can see our profiles than reporting that they can see our AWS tokens.

Copy link
Copy Markdown
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Do we even need a config option to enable it? Is there any good use case for cmdline in our databases?

@colega
Copy link
Copy Markdown
Contributor Author

colega commented Feb 12, 2026

I never used it, I have to admit I didn't even know it existed, but who knows how people use dskit. I think not leaving an option is too radical.

@56quarters
Copy link
Copy Markdown
Contributor

I never used it, I have to admit I didn't even know it existed, but who knows how people use dskit. I think not leaving an option is too radical.

Options tend to proliferate with the Server in particular. If you add an option now it will never be removed because nobody will be confident enough. I'd rather explicitly disable anything we aren't expecting under /debug/pprof and add options in the future if it's needed.

@colega colega force-pushed the feat/disable-pprof-cmdline-by-default branch from 5cc5af6 to 7d56aa7 Compare February 13, 2026 07:52
@colega colega changed the title feat(server): make /debug/pprof/cmdline opt-in feat(server): always disable /debug/pprof/cmdline, return 404 Feb 13, 2026
@colega
Copy link
Copy Markdown
Contributor Author

colega commented Feb 13, 2026

Okay, I removed the the option and made it respond 404 always.

Comment thread server/server_test.go Outdated

func TestPprofCmdlineDisabled(t *testing.T) {
cfg := Config{}
cfg.RegisterFlags(flag.NewFlagSet("", flag.PanicOnError))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is done with flagext.DefaultValues(&cfg) elsewhere

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.

Actually this file doesn't use flagext.DefaultValues, but I don't think it's worth discussing this so I replaced it.

Comment thread server/server_test.go Outdated
cfg.RegisterFlags(flag.NewFlagSet("", flag.PanicOnError))
setAutoAssignedPorts("tcp", &cfg)
cfg.Registerer = prometheus.NewPedanticRegistry()
cfg.Gatherer = prometheus.NewRegistry()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are these different objects?

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.

I removed them completely, the test passes without them.

Signed-off-by: Oleg Zaytsev <[email protected]>
@colega colega enabled auto-merge (squash) February 13, 2026 16:33
@colega colega merged commit ab41154 into main Feb 13, 2026
13 checks passed
@colega colega deleted the feat/disable-pprof-cmdline-by-default branch February 13, 2026 16:46
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.

4 participants