Repository navigation
Description
pkg/profiling has no importer, and the two settings that looked like they enabled it — global.enable_pprof and global.profile_port — were removed in v0.11.0 rather than wired (#202/#211/#212). This issue is where the package's fate gets decided.
What is actually there
pkg/profiling builds an HTTP server and registers the standard net/http/pprof handlers, plus its own /memory/gc and /memory/free. Nothing imports it: no cmd/, no internal/adapter, no test outside the package.
Three problems, in order of seriousness:
/memory/gcand/memory/freeare mutating handlers with no authentication. AGETfrom anything that can reach the port forces a garbage collection or returns memory to the OS. That is a remote latency knob on a filesystem.- It binds
fmt.Sprintf(":%d", port)— every interface. The same defect as metrics and health listeners bind all interfaces, and the address is not configurable #211, in a second server. A pprof endpoint publishes goroutine stacks, heap contents and command line to whoever asks. - The bind is on a goroutine that logs and returns, so a mount that asked for profiling and did not get it looks identical to one that did.
global.profile_port defaulted to 6060 and global.enable_pprof defaulted to false, and neither reached this package or any other. Wiring them inside the change that stopped binding two unauthenticated listeners would have been the wrong trade on the strength of a boolean nothing read.
The decision
Either:
(a) Delete pkg/profiling. net/http/pprof is four lines against a mux an operator already controls, and the package's only additions over the standard handlers are the two mutating endpoints that should not exist. A profiling story that reads "import net/http/pprof in a debug build" is honest and costs nothing to maintain.
(b) Keep it, and make it safe to enable. Then it needs, as one change: an addr setting inside a block with its own enabled flag (matching monitoring.metrics), defaulting to loopback; a synchronous bind whose error propagates; the mutating handlers deleted or moved behind an explicit second flag; a Shutdown the adapter calls; and a test that asserts the bound address rather than that something is listening.
(a) is the recommendation. The audit found no caller, no test, and no documentation that describes profiling as working.
Either way
SECURITY.mdcurrently states plainly that no pprof listener is started at any address, and links here. If (b) lands, that paragraph changes.internal/config/config.go'sGlobalConfigdoc comment explains why the two keys were removed rather than wired, and links here.
Activity
fix: one address per listener, beside the flag that enables it (#246)
scttfrdmn commentedon Aug 5, 2026
Three measurements before the decision this issue asks for, one of which changes what option (a) means.
pkg/profilingis mostly not the pprof serverThe issue describes the package as "builds an HTTP server and registers the standard
net/http/pprofhandlers, plus its own/memory/gcand/memory/free". That is one function out of thirty-three.pkg/profiling/memory.gois 592 lines and its actual surface is a memory monitor:MemoryMonitorwith a sampling loop, a concurrent GC monitor, and a ring ofMemorySamplesAlertThresholds/Alert/AlertLevel/AlertCallback— a threshold-alerting system with registered callbacksGetMemoryStats,GetSamples,GetSamplesSince,GetGoroutineCount,takeBaselinestartPprofServerand four handlers — the part this issue is aboutSo "delete
pkg/profiling" as written deletes a monitor to remove a listener. That may still be the right call, but it should be made knowing that is what it is, and the issue's stated justification — "net/http/pprofis four lines against a mux an operator already controls" — only covers the last item on that list.There are two memory monitors, and the documented one is the other one
pkg/memmonalso exists: 595 lines inmonitor.goplus 321 inprofiler.go, and it declares a type also calledMemoryMonitorwith aNewMemoryMonitorconstructor, amonitorLoop,takeSample, andanalyzeMemory. It has no importer either — verified for the module path across the tree, same aspkg/profiling.The two are not documented equally.
docs/memory-monitoring.mdis a 253-line guide, and every line of it is aboutpkg/memmon— "Thepkg/memmonpackage provides: real-time memory monitoring, automatic leak detection, object tracking, memory profiling, alert system", with a Quick Start that importspkg/memmonand callsmemmon.DefaultMonitorConfig().pkg/profilingappears in no user-facing document at all; its only mention anywhere outside itself is the pointer ininternal/config/config.go:155that this issue's predecessor added.pkg/memmondoes not bind a listener — noListenAndServe, nohttp.Server, no handler registration. So the security half of this issue is specific topkg/profiling, while the documented-feature half belongs topkg/memmon.That makes the real question larger than this issue's framing: the repo has two unimported implementations of the same concept, one documented and one not, and the one carrying the unauthenticated listener is the undocumented one. Deleting
pkg/profilingalone removes the security exposure and leaves a documented-but-deadpkg/memmonbehind — which is the shape of defect the audit was about, just relocated.Both have tests, and they pass
pkg/profilingis at 75.4% coverage,pkg/memmonat 51.9%, andgo test -raceis green for both. Worth stating because it affects how deletion reads in the coverage numbers, and because a package with 682 lines of passing tests does not look dead from any automated angle — which is presumably part of why both survived this long.Effect on the recommendation
The issue recommends (a), delete. I still think a variant of (a) is right, but it should be one decision over both packages rather than one over half of one:
pkg/profilingoutright. It is undocumented, has no importer, and carries the two unauthenticated mutating handlers plus the every-interface bind. Nothing is lost thatpkg/memmondoes not already claim to do.pkg/memmonseparately: either wire it to something (it is whatdocs/memory-monitoring.mdpromises, so the honest options are "make the doc true" or "delete the doc with the package"), or delete both and say plainly that memory monitoring is not a feature.Doing 1 without 2 leaves
docs/memory-monitoring.mddescribing a package no code path reaches, which is exactly the pattern in the ~190 documentation overclaims tracked elsewhere.I have not touched either package; this is just the measurement. Happy to implement whichever shape is wanted, but "delete
pkg/profiling" and "delete the memory-monitoring story" are different decisions and the second one is not mine to make.Either way
The two follow-ups this issue already lists still hold —
SECURITY.md's paragraph stating no pprof listener is started, andinternal/config/config.go'sGlobalConfigcomment explaining whyenable_pprof/profile_portwere removed rather than wired. Both link here, so both need touching by whatever lands.chore: a docs path that never existed, and four duplicate link defini…
chore: a docs path that never existed, and four duplicate link defini…
chore: a docs path that never existed, and four duplicate link defini…
fix(docs): the Not-implemented table and its refusals cite open issue…