Skip to content

fix(security): TLS ssl_verify hardcoding and credential encryption issues#13203

Merged
Baoyuantop merged 1 commit into
apache:masterfrom
AlinsRan:fix/tls-ssl-verify-credential-encryption
Apr 17, 2026
Merged

fix(security): TLS ssl_verify hardcoding and credential encryption issues#13203
Baoyuantop merged 1 commit into
apache:masterfrom
AlinsRan:fix/tls-ssl-verify-credential-encryption

Conversation

@AlinsRan

@AlinsRan AlinsRan commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix multiple TLS and credential-encryption vulnerabilities across several plugins, and a bug in the shared check_https utility.

wolf-rbac: ssl_verify hardcoded to false

http_req() passed ssl_verify = false unconditionally to resty.http, so TLS certificate verification was always disabled regardless of the server endpoint. There was also no schema field to let users enable it.

Additionally, request_to_wolf_server() logged the full response body at both info and error level — core.log.info("request [...] success! response body:", core.json.delay_encode(body)) — which could leak wolf tokens and user PII into the error log.

Fix: Add ssl_verify boolean field to the consumer schema (nil by default). Thread it through http_req(), http_get(), check_url_permission(), and request_to_wolf_server(). Remove full response body from log statements; retain only body.reason on error.

ai-rag: Azure HTTPS calls without certificate verification

Both azure_openai.get_embeddings() and azure_ai_search.search() called httpc:request_uri(endpoint, { ..., body = body_tab }) with no ssl_verify field, so resty.http performed no certificate verification for the Azure HTTPS endpoints.

Fix: Add ssl_verify boolean field (default true) to the plugin schema. Pass it to both driver request_uri() calls. Add check_https warnings for embeddings_provider.azure_openai.endpoint and vector_search_provider.azure_ai_search.endpoint.

aws-lambda: IAM credentials stored as plaintext in etcd

The plugin had no encrypt_fields declaration, so authorization.apikey, authorization.iam.accesskey, and authorization.iam.secretkey were stored as plaintext strings in etcd — e.g. "secretkey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY".

Fix: Add plugin.schema.encrypt_fields covering all three credential paths.

core/utils: check_https exits loop early on first missing field

check_https used return when a field was nil or get_root_conf returned nothing, which exited the entire loop instead of moving to the next field. For example:

core.utils.check_https({
    "embeddings_provider.azure_openai.endpoint",    -- if this is absent ...
    "vector_search_provider.azure_ai_search.endpoint",  -- ... this is never checked
}, conf, plugin_name)

get_root_conf also had no guard when an intermediate path segment was not a table, which could cause a nil-index panic.

Fix: Replace return with goto continue so all fields are always checked. Add a type(conf) ~= "table" guard in get_root_conf to return nil, nil safely.

Changes

  • apisix/core/utils.luaget_root_conf: return nil, nil if intermediate path is not a table; check_https: goto continue instead of return
  • apisix/plugins/wolf-rbac.lua — add ssl_verify field; thread through all HTTP call sites; remove response body from logs
  • apisix/plugins/ai-rag.lua — add ssl_verify field (default true); add check_https and check_tls_bool in check_schema; pass ssl_verify to both driver calls
  • apisix/plugins/ai-rag/embeddings/azure_openai.lua — accept and pass ssl_verify to request_uri
  • apisix/plugins/ai-rag/vector-search/azure_ai_search.lua — accept and pass ssl_verify to request_uri
  • apisix/plugins/aws-lambda.lua — add encrypt_fields for authorization.apikey, authorization.iam.accesskey, authorization.iam.secretkey

Tests

  • t/plugin/wolf-rbac.t — TEST 38/39: monkey-patch resty.http to intercept request_uri opts and assert ssl_verify is forwarded correctly for both false and true; TEST 40: schema rejects non-boolean value
  • t/plugin/ai-rag.t — TEST 15/16: ssl_verify defaults to true and can be set to false; TEST 17: monkey-patch resty.http to assert ssl_verify = false reaches both the embeddings and vector-search request_uri calls
  • t/plugin/aws-lambda.t — TEST 7: cleanup route; TEST 8: write credentials via admin API, read directly from etcd, assert all three fields are stored as ciphertext while admin API returns plaintext

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Apr 13, 2026
@AlinsRan
AlinsRan force-pushed the fix/tls-ssl-verify-credential-encryption branch 2 times, most recently from e74a195 to 633ffc6 Compare April 14, 2026 09:14
…sues

- wolf-rbac: add configurable ssl_verify field (default nil/false) to
  plugin schema; thread through http_req/http_get/check_url_permission/
  request_to_wolf_server; fix check_schema to run schema validation
  before check_https; add check_tls_bool call
- ai-rag: add ssl_verify field (default true) to plugin schema; pass
  ssl_verify to embeddings and vector-search driver request_uri calls;
  also remove stray 'type = object' line from properties table
- ai-rag/embeddings/azure_openai: accept ssl_verify param and pass to
  request_uri
- ai-rag/vector-search/azure_ai_search: accept ssl_verify param and
  pass to request_uri
- aws-lambda: add encrypt_fields for authorization.apikey,
  authorization.iam.accesskey, and authorization.iam.secretkey so
  credentials are stored encrypted at rest in etcd
@AlinsRan
AlinsRan force-pushed the fix/tls-ssl-verify-credential-encryption branch from 633ffc6 to f35a930 Compare April 15, 2026 00:22
@Baoyuantop
Baoyuantop merged commit 9b1e546 into apache:master Apr 17, 2026
31 of 35 checks passed
@shreemaan-abhishek shreemaan-abhishek mentioned this pull request Jun 11, 2026
5 tasks
wistefan pushed a commit to wistefan/apisix that referenced this pull request Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants