Skip to content

branch-4.1: [fix](jdbc) Harden JDBC driver URL validation and remove file-upload HTTP API - #67149

Open
CalvinKirs wants to merge 1 commit into
apache:branch-4.1from
CalvinKirs:backport-65987-branch-4.1
Open

branch-4.1: [fix](jdbc) Harden JDBC driver URL validation and remove file-upload HTTP API#67149
CalvinKirs wants to merge 1 commit into
apache:branch-4.1from
CalvinKirs:backport-65987-branch-4.1

Conversation

@CalvinKirs

Copy link
Copy Markdown
Member

…HTTP API (apache#65987)

Hardens JDBC driver loading, locks down security-sensitive configs, and
removes an
unnecessary file-upload attack surface on the FE.

| Area | Change |
|---|---|
| `jdbc_driver_secure_path` matching | Component-based (structural)
instead of a raw string prefix. `file://` URLs are decoded once via
`URI.getPath()` and compared with `Path.startsWith`; `http(s)` URLs
compare scheme/host/port, **user-info and query**, plus a
component-based path prefix. Closes prefix-confusion, path-traversal
(literal **and** percent-encoded `%2e%2e`), and query/user-info
bypasses. `*` and empty still mean allow-all (unchanged). |
| Fail-closed parsing | A `driver_url` that cannot be parsed as a URI is
now rejected instead of being accepted. |
| Mandatory CREATE/ALTER rule | New
`JdbcDorisConnector.checkDriverUrlSecurityRule()`, invoked from the
connector's `validateProperties()` (run by `checkProperties()` on both
CREATE and ALTER, both `!isReplay`). It **cannot be turned off**:
rejects any `..` segment (decoded), and requires a scheme-less
`driver_url` to be a bare `[A-Za-z0-9._-]+.jar` name resolved under
`jdbc_drivers_dir`. Never runs during replay or at query time. |
| Config immutability | `jdbc_driver_url_white_list`,
`s3_load_endpoint_white_list`, `force_sqlserver_jdbc_encrypt_false` are
now settable only in `fe.conf` (non-mutable). |
| Removed endpoint | `UploadAction` (`/api/{ns}/{db}/{tbl}/upload`) and
its `LoadSubmitter` / `TmpFileMgr` helpers, plus the now-orphaned
`http_load_submitter_max_worker_threads` config. |

| # | Before | After | Impact / who is affected |
|---|---|---|---|
| 1 | `POST/PUT/GET/DELETE /api/{ns}/{db}/{tbl}/upload` uploaded a file
to FE and stream-loaded it | Endpoint **removed** (404) | Web-UI "Data
Import" page / scripts hitting this route. Stream Load, Broker Load,
Routine Load, INSERT, S3 Load, CopyInto are **unaffected**. |
| 2 | `driver_url` with `..`, encoded `%2e%2e`, or a scheme-less path
with directories was accepted at CREATE (and never re-checked on ALTER)
| Rejected at **CREATE and ALTER CATALOG** | Only new/altered catalogs.
Existing catalogs are **not** re-validated (replay and queries
unaffected). |
| 3 | `jdbc_driver_secure_path` matched by raw string prefix; parse
failures were let through | Structural matching; parse failures rejected
(fail-closed) | Driver URLs that only passed by a coincidental prefix,
via `..`, `%2e%2e`, or a differing query/user-info are now rejected.
Legitimate URLs are unaffected. `*` and empty both still mean allow-all,
so default deployments see no change. |
| 4 | `jdbc_driver_url_white_list`, `s3_load_endpoint_white_list`,
`force_sqlserver_jdbc_encrypt_false` were runtime-mutable | Non-mutable
(fe.conf only, restart to take effect) | Scripts using `ADMIN SET
FRONTEND CONFIG` for these now get a "not mutable" error. |
| 5 | `http_load_submitter_max_worker_threads` config existed | Removed
| Old `fe.conf` entries get the existing unknown-key warning. |

| Config | Before | After |
|---|---|---|
| `jdbc_driver_url_white_list` | `mutable = true` | fe.conf only
(non-mutable) |
| `s3_load_endpoint_white_list` | `mutable = true` | fe.conf only
(non-mutable) |
| `force_sqlserver_jdbc_encrypt_false` | `mutable = true` | fe.conf only
(non-mutable) |
| `jdbc_driver_secure_path` | raw string-prefix match | structural
(component-based) match; `*`/empty still allow-all |
| `http_load_submitter_max_worker_threads` | present | removed |

Removed the `/api/{ns}/{db}/{tbl}/upload` file-upload endpoint. Hardened
JDBC
driver URL validation (structural `jdbc_driver_secure_path` matching
incl.
encoded-traversal and query/user-info handling, fail-closed parsing, and
a
mandatory CREATE/ALTER rule that forbids path traversal and requires a
plain jar
file name); `*` and empty `jdbc_driver_secure_path` still mean
allow-all.
`jdbc_driver_url_white_list`, `s3_load_endpoint_white_list` and
`force_sqlserver_jdbc_encrypt_false` are now settable only in `fe.conf`.

- Test <!-- At least one of them must be included. -->
    - [ ] Regression test
    - [x] Unit Test
    - [ ] Manual test (add detailed scripts or steps below)
    - [ ] No need to test or manual test. Explain why:

- Behavior changed:
    - [ ] No.
    - [x] Yes. <!-- See the "Behavior changes" table above. -->

- Does this need documentation?
    - [ ] No.
- [x] Yes. <!-- The removed endpoint and the config/validation changes
should be documented. -->
@CalvinKirs
CalvinKirs requested a review from yiguolei as a code owner August 26, 2026 03:47
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@CalvinKirs

Copy link
Copy Markdown
Member Author

run buildall

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.

2 participants