Skip to content

Commit 6d38b7a

Browse files
committed
docs: clarify 64 KiB response-body buffer in authz plugin docs
Adds a "Response body size and partial buffering" subsection to docs/extend/plugins_authorization.md documenting the 64 KiB maxBufferSize constant in the daemon's internal responseModifier (pkg/authorization/response.go in moby/moby) and the practical implications for plugins that use ResponseBody inspection. The existing docs (lines 81-87) say streaming endpoints such as logs and events send only the HTTP request to plugins, but don't explain the underlying mechanism. Plugin authors building response-body redaction or content-filtering can be surprised when the same effect happens on non-listed endpoints whose response is produced through multiple writes exceeding the buffer or via an io.WriteFlusher. The 64 KiB buffer is observable from the public moby source, so this PR is documentation catching up to existing behavior — not a contract change. Signed-off-by: Matteo Panzeri <matteo1782@gmail.com>
1 parent a6d013f commit 6d38b7a

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

docs/extend/plugins_authorization.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,31 @@ passed to the authorization plugins. For commands that return chunked HTTP
8686
response, such as `logs` and `events`, only the HTTP request is sent to the
8787
authorization plugins.
8888

89+
### Response body size and partial buffering
90+
91+
The internal buffer that holds the response body between the daemon's HTTP
92+
handler and the plugin's response authorization callback (`responseModifier`,
93+
defined in [`pkg/authorization/response.go`](https://github.com/moby/moby/blob/master/pkg/authorization/response.go))
94+
has a fixed capacity of 64 KiB (`maxBufferSize`).
95+
96+
For most non-streaming endpoints the full response is buffered for plugin
97+
inspection regardless of total size, because Go's `encoding/json` encoder
98+
serializes the complete payload into a single underlying write. The
99+
streaming-response exclusion noted above (for example, `logs` and `events`)
100+
is the practical effect of this 64 KiB threshold combined with the
101+
`io.WriteFlusher` write pattern used by streaming handlers, where each write
102+
is immediately drained to the client and is therefore no longer available
103+
for plugin inspection by the time the handler returns.
104+
105+
> [!NOTE]
106+
> Plugins that depend on `ResponseBody` inspection for redaction or
107+
> content-filtering should restrict their policies to endpoints whose
108+
> response is produced as a single write (typical of REST-style API
109+
> responses). For commands whose responses are streamed or are likely to
110+
> exceed the buffer through multiple writes, do not rely on `ResponseBody`
111+
> for security-relevant decisions; perform the filtering in a separate
112+
> layer in front of the daemon.
113+
89114
During request/response processing, some authorization flows might
90115
need to do additional queries to the Docker daemon. To complete such flows,
91116
plugins can call the daemon API similar to a regular user. To enable these

0 commit comments

Comments
 (0)