Skip to content

refuse wire-blocked component names given as bare strings in request parseContext - #3351

Merged
tballison merged 1 commit into
apache:mainfrom
mrdevel2002-ui:wire-block-bare-embedding-filter
Oct 16, 2026
Merged

tballison merged 1 commit into
apache:mainfrom
mrdevel2002-ui:wire-block-bare-embedding-filter

Conversation

@mrdevel2002-ui

Copy link
Copy Markdown
Contributor

ParseContextDeserializer's wire gate refuses openai-embedding-filter and jina-embedding-filter only when they appear as object keys. scanForBlocked skips bare strings as inert defaults, but these two are MetadataFilters, so a request parseContext of {"metadata-filters":["openai-embedding-filter"]} (tika-server multipart config part, gRPC parse_context_json, FetchEmitTuple parseContext) passes the gate and resolveArrayConfig binds a working no-arg filter that POSTs document text to its default endpoint, which ComponentNameResolver says a wire request must never be able to do. The textual check is limited to the wire-blocked names, so type-blocked bare strings keep failing at the assignability check as before; the new cases in WireRestrictedParseContextTest and TikaResourceTest fail on main.

There is no JIRA issue for this yet; I will open one and add the TIKA-XXXX prefix to the title and commit before this is merged.

scanForBlocked only checked object keys, so a request parseContext of
{"metadata-filters":["openai-embedding-filter"]} passed the gate and
resolved to a working embedding filter bound into the request.

Generated-by: Claude Code (Claude Opus 5.5)
@THausherr
THausherr requested a balanced review from Copilot October 16, 2026 03:33

Copilot AI left a comment

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open findings
What changed in this PR

This PR closes a wire-gating bypass where wire-blocked component names could be provided as bare strings (e.g., in metadata-filters) and still resolve to a runnable default instance.

Changes:

  • Extend parseContext wire-gate scanning to reject bare-string occurrences of wire-blocked component names.
  • Add regression tests covering bare-string wire-blocked references in both server merging and restricted deserialization.
  • Update deserializer documentation to reflect the new bare-string handling.
File Description
tika-server/​tika-server-standard/​src/​test/​java/​org/​apache/​tika/​server/​standard/​TikaResourceTest.java Adds a server-side regression test ensuring bare-string metadata-filters are rejected from request parseContext.
tika-serialization/​src/​test/​java/​org/​apache/​tika/​serialization/​WireRestrictedParseContextTest.java Adds a serialization-layer regression test for rejecting bare-string wire-blocked component names.
tika-serialization/​src/​main/​java/​org/​apache/​tika/​serialization/​serdes/​ParseContextDeserializer.java Implements bare-string checks for wire-blocked names during subtree scanning and updates related Javadocs.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +212 to +215
} else if (node.isTextual() && ComponentNameResolver.isWireBlockedName(node.asText())) {
throw new IOException("Component '" + node.asText() + "' may not be supplied via a "
+ "request parseContext. It must be configured server-side in the Tika config, "
+ "not at request time.");
Comment on lines +165 to +166
Exception e = assertThrows(Exception.class,
() -> restrictedMapper().readValue(json, ParseContext.class), name);
Comment on lines +212 to +215
} else if (node.isTextual() && ComponentNameResolver.isWireBlockedName(node.asText())) {
throw new IOException("Component '" + node.asText() + "' may not be supplied via a "
+ "request parseContext. It must be configured server-side in the Tika config, "
+ "not at request time.");
@tballison
tballison merged commit 4847f78 into apache:main Oct 16, 2026
4 checks passed
@tballison

Copy link
Copy Markdown
Contributor

This will largely be obviated in 4.2.0, I hope. Until then, this makes sense. Thank you for opening this.

@mrdevel2002-ui

Copy link
Copy Markdown
Contributor Author

Thanks for merging. Makes sense as a stopgap until 4.2.0 reworks this.

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.

3 participants