Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External url service is always treating relative path URLs without protocol and host name as external #115561

Closed
flash1293 opened this issue Oct 19, 2021 · 4 comments · Fixed by #116404
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!

Comments

@flash1293
Copy link
Contributor

flash1293 commented Oct 19, 2021

Kibana version: master

Describe the bug: As discussed in #114093 , the validateUrl method of the external url service is not correctly handling URLs which only consist out of a relative path (without leading slash) and optionally a hash.

Steps to reproduce:
See example here: #114093 (review)

Expected behavior:
User should be redirected

Any additional context:

The logic for checking whether a given URL is internal looks like this:

const isInternalURL =
url.origin === base.origin &&
(!serverBasePath || url.pathname.startsWith(`${serverBasePath}/`));

It's not accounting for the case of non-fully qualified URLs (no protocol and no host) which are not specifying the whole path (starting with a leading slash), but are relative to the current url (no leading slash):
Example (assuming the users current location is http://localhost:1234/mybasepath/app/visualizations#/edit/4344):

  • http://localhost:1234/mybasepath/app/dashboards#/view/234345 recognized as internal
  • /mybasepath/app/dashboards#/view/234345 recognized as internal
  • dashboards#/view/234345 wrongly treated as external URL

I suggest to resolve this by fully qualifying the URL being passed to the validation function before doing internal/external checks using the resolve method of the url package: https://www.npmjs.com/package/url#urlresolvefrom-to

It behaves like the browser would if the URL is used as href for an anchor element (which is exactly what Vega and TSVB are doing)

It would be great if this bug could be fixed for 7.16 as external url policy support for Vega and TSVB just got introduced and might break URLs which are working in 7.15

@flash1293 flash1293 added bug Fixes for quality problems that affect the customer experience Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! labels Oct 19, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

@lukeelmers
Copy link
Member

@jportner Is security team planning to track this one, or should core be keeping an eye on it?

@jportner
Copy link
Contributor

We spoke to @flash1293 offline, I think we agreed on a fix and he's going to submit a PR soon 👍 thanks for checking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants