Skip to content

dbeaver/pro#10559 Fix URL redirection from remote source - #4670

Open
dgr-dbeaver wants to merge 9 commits into
develfrom
10559-fix-url-redirection-from-remote-source
Open

dgr-dbeaver wants to merge 9 commits into
develfrom
10559-fix-url-redirection-from-remote-source

Conversation

@dgr-dbeaver

Copy link
Copy Markdown
Contributor

Closes dbeaver/pro#10559

Summary

  • Build HTTPS redirects only from hosts explicitly configured in supportedHosts
  • Reject unsafe redirect authorities and request paths
  • Add regression tests for trusted and untrusted redirects

Testing

  • mvn verify -f server/product/aggregate/pom.xml -Dtest=RequestHostFilterTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false -rf :io.cloudbeaver.model

@codacy-production

codacy-production Bot commented Sep 17, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 medium

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Complexity 1 medium

View in Codacy

🟢 Metrics 8 complexity

Metric Results
Complexity 8

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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.

Copilot review overview

🟡 Changes recommended

Host allowlisting currently relies on exact host[:port] string equality, which can incorrectly reject equivalent default-port configurations (e.g., example.com:443 vs https://example.com).

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

This PR hardens CloudBeaver CE request-host handling to prevent unsafe HTTPS redirections by only redirecting/allowing hosts explicitly configured in supportedHosts, and by validating redirect authorities/paths.

Changes:

  • Tighten RequestHostFilter redirect/host validation and construct redirects via validated URI building.
  • Extend ServletAppUtils.getOriginFromRequest to accept an explicit ServletApplication (used by RequestHostFilter) and refactor origin normalization.
  • Add platform regression tests for trusted/untrusted redirect scenarios and include them in the CE test suite.
File Description
server/​test/​io.cloudbeaver.test.platform/​src/​io/​cloudbeaver/​test/​platform/​CEServerTestSuite.java Adds the new Jetty host filter regression tests to the CE test suite.
server/​test/​io.cloudbeaver.test.platform/​src/​io/​cloudbeaver/​server/​jetty/​RequestHostFilterTest.java Introduces regression tests for HTTPS redirect behavior and unsafe redirect inputs.
server/​bundles/​io.cloudbeaver.server.ce/​src/​io/​cloudbeaver/​server/​jetty/​RequestHostFilter.java Implements safer host allowlisting + redirect URI construction/validation.
server/​bundles/​io.cloudbeaver.server.ce/​META-INF/​MANIFEST.MF Exports io.cloudbeaver.server.jetty so tests/consumers can access the filter package.
server/​bundles/​io.cloudbeaver.model/​src/​io/​cloudbeaver/​utils/​ServletAppUtils.java Adds an overload to compute origin using a provided application instance; refactors origin derivation helpers.

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

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.

Copilot review overview

🟡 Changes recommended

There are security- and runtime-impacting edge cases (fail-open behavior on origin parsing errors, potential OSGi split-package export, and uncaught forwarded-host parsing exceptions) that should be addressed before merge.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity

Open (2)
Resolved since last review (1)

Comment on lines 14 to 21
Export-Package: io.cloudbeaver,
io.cloudbeaver.model,
io.cloudbeaver.model.config,
io.cloudbeaver.server,
io.cloudbeaver.server.jetty,
io.cloudbeaver.service,
io.cloudbeaver.service.core,
io.cloudbeaver.service.session
Comment on lines 401 to +404
URI uri = URI.create(origin);
int port = uri.getPort();
if (CommonUtils.isNotEmpty(request.getHeader(HEADER_FORWARDED_PORT))) {
try {
port = Integer.parseInt(request.getHeader(HEADER_FORWARDED_PORT));
} catch (NumberFormatException e) {
log.error("Failed to parse port from header: " + request.getHeader(HEADER_FORWARDED_PORT), e);
}
}

URI forwardedHostUri = parseForwardedHost(forwardedHost);
int forwardedHostPort = forwardedHostUri == null ? -1 : forwardedHostUri.getPort();
int port = getForwardedPort(request, forwardedHostPort > -1 ? forwardedHostPort : uri.getPort());
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