Repository navigation
Hardening AI functions (deny cleartext endpoints, bound API calls, sanitize error logs) - #111286
Conversation
|
Workflow [PR], commit [37ac4bf] Summary: ✅
AI ReviewSummaryThis PR hardens the experimental AI functions by rejecting non-loopback cleartext endpoints by default, defaulting Final Verdict✅ No new findings. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
…vior Record ai_function_allow_insecure_endpoint as true -> false in the settings history so `compatibility` set to a version before 26.7 opts back into allowing plaintext remote endpoints, instead of leaving the new guard on. Addresses the review on PR #111286. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
|
c79c957 to
7a38a0a
Compare
…vior Record ai_function_allow_insecure_endpoint as true -> false in the settings history so `compatibility` set to a version before 26.7 opts back into allowing plaintext remote endpoints, instead of leaving the new guard on. Addresses the review on PR #111286. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
7a38a0a to
89d63b1
Compare
…vior Record ai_function_allow_insecure_endpoint as true -> false in the settings history so `compatibility` set to a version before 26.7 opts back into allowing plaintext remote endpoints, instead of leaving the new guard on. Addresses the review on PR #111286. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
@george-larionov Could we split this PR in two?
|
|
@rschu1ze I discussed this with @santrancisco, and the verdict was that it's not worth it to make the HTTP behavior global since it would likely break too many things (e.g. internal endpoints) and not really gain us much security since the addresses in question are internal or don't need encryption. @santrancisco feel free to comment if you have anything to add. |
Refuse a non-https AI named-collection endpoint whose host is not loopback, so enabling the experimental AI functions does not silently send prompts and API keys over an unencrypted connection. Loopback endpoints (a local http model server) stay allowed. Add ai_function_allow_insecure_endpoint (default false) to opt out. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Warn that AI function output is influenced by the input text and must be treated as untrusted, especially when the input comes from external or unsanitized sources and the output is used further in the pipeline. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Bound outbound AI function HTTP calls per query by default (previously 0 = unlimited), so an enabled AI workload cannot dispatch unbounded requests. This is the only such bound for providers that do not report token usage. Restore the old behavior via compatibility < 26.7 or by setting it back to 0. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Both providers built the error exception from the provider's HTTP response, whose control characters could forge log lines or corrupt a terminal when logged. Factor the two near-identical extractProviderError copies into a shared formatProviderError that replaces control characters (including newlines) with spaces, applied to both the parsed error message/type and the raw-body fallback. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…vior Record ai_function_allow_insecure_endpoint as true -> false in the settings history so `compatibility` set to a version before 26.7 opts back into allowing plaintext remote endpoints, instead of leaving the new guard on. Addresses the review on PR #111286. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The default of ai_function_max_api_calls_per_query changed from 0 to 1000, which the settings-dump section of 03300_ai_functions checks. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add integration cases exercising both branches of formatProviderError: a structured error whose message/type carry control characters, and a non-JSON error body that falls back to the truncated raw body. Both assert the control characters are replaced with spaces (no forged log lines) while the text stays readable. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add 04628_ai_functions_compatibility_defaults: with compatibility = '26.6' a remote http endpoint stops being rejected and ai_function_max_api_calls_per_query goes back to 0. This pins the previous_value pairs in SettingsChangesHistory, which 02995 does not check. Also rename sanitizeTextForAI to sanitizeForModel to pair with sanitizeForLog, simplify formatProviderError, and trim docs. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
89d63b1 to
37ac4bf
Compare
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 94/99 (94.95%) · Uncovered code |
|
@groeneai plz add test for ai_function_max_api_calls_per_query |
@zlareb1 That would duplicate the coverage in tests/integration/test_ai_functions/test.py. @groeneai Kindly ignore #111286 (comment) |
When users enable the experimental AI functions, several defaults leave them exposed. This PR hardens the AI functions along three axes:
endpointthat would send prompts and the API key over an unencrypted connection to a remote host is now rejected. Loopback endpoints (e.g. a localhttp://localhostmodel server) remain allowed. The new settingai_function_allow_insecure_endpoint(defaultfalse) overrides the check.ai_function_max_api_calls_per_querynow defaults to1000instead of0(unlimited), so an enabled workload cannot dispatch an unbounded number of provider requests. It is the only such bound for providers that do not report token usage. The previous behavior is restored viacompatibilityset to a version before26.7, or by setting it back to0.formatProviderErrorthat replaces control characters (including newlines) in both the parsed error fields and the raw-body fallback.The prompt-injection risk of feeding AI output into downstream steps is also documented.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Harden the experimental AI functions: deny insecure (
http) endpoints to remote hosts by default (new settingai_function_allow_insecure_endpoint), bound outbound API calls per query by default (ai_function_max_api_calls_per_querynow defaults to1000), and sanitize provider error responses written to the logs.Version info
26.8.1.727(included in26.8and later)