Średnia

Server side request forgery in SwaggerUI

  • Ujawniono: 09.12.2021
  • Aktualizacja: 11.10.2026 11:23

SwaggerUI supports displaying remote OpenAPI definitions through the ?url parameter. This enables robust demonstration capabilities on sites like petstore.swagger.io, editor.swagger.io, and similar sites, where users often want to see what their OpenAPI definitions would look like rendered.

However, this functionality may pose a risk for users who host their own SwaggerUI instances. In particular, including remote OpenAPI definitions opens a vector for phishing attacks by abusing the trusted names/domains of self-hosted instances.

An example scenario abusing this functionality could take the following form:

  • https://example.com/api-docs hosts a version of SwaggerUI with ?url= query parameter enabled.
  • Users will trust the domain https://example.com and the contents of the OpenAPI definition.
  • A malicious actor may craft a similar OpenAPI definition and service that responds to the defined APIs at https://evildomain.
  • Users mistakenly click a phishing URL like https://example.com/api-docs?url=https://evildomain/fakeapi.yaml and enters sensitive data via the "Try-it-out" feature.

We do want to stress that this attack vector is limited to scenarios that actively trick users into divulging sensitive information. The ease of this is highly contextual and, therefore, the threat model may be different for individual users and organizations. It is not possible to perform non-interactive attacks (e.g., cross-site scripting or code injection) through this mechanism.

Resolution

We've made the decision to disable query parameters (#4872) by default starting with SwaggerUI version 4.1.3. Please update to this version when it becomes available (ETA: 2021 December). Users will still be able to be re-enable the options at their discretion. We'll continue to enable query parameters on the Swagger demo sites.

Workaround

If you host a version of SwaggerUI and wish to mitigate this issue immediately, you are encouraged to add the following custom plugin code:

js
SwaggerUI({
  //  ...other configuration options,
  plugins: [function UrlParamDisablePlugin() {
    return {
      statePlugins: {
        spec: {
          wrapActions: {
            // Remove the ?url parameter from loading an external OpenAPI definition.
            updateUrl: (oriAction) => (payload) => {
              const url = new URL(window.location.href)
              if (url.searchParams.has('url')) {
                url.searchParams.delete('url')
                window.location.replace(url.toString())
              }
              return oriAction(payload)
            }
          }
        }
      }
    }
  }],
})

Future UX work

Through the exploration of this issue, it became apparent that users may not be aware to which web server the Try-it-out function will send requests. While this information is currently presented at the top of the page, understanding may improve by displaying it closer to the "Execute" button where requests are actually made. We'll be exploring these UX improvements over the coming months and welcome community input. Please create a Feature Request under the GitHub Issue tab to start a conversation with us and the community.

Reflected XSS attack

Warning in versions < 3.38.0, it is possible to combine the URL options (as mentioned above) with a vulnerability in DOMPurify (https://www.cvedetails.com/cve/CVE-2020-26870/) to create a reflected XSS vector. If your version of Swagger UI is older than 3.38.0, we suggest you upgrade or implement the workaround as mentioned above.

Czego dotyczy

Kliknij technologię, aby zobaczyć wszystkie dotyczące jej podatności.

PlatformaPaczkaPodatne wersjePoprawka w wersji
Paczka npm swagger-ui < 4.1.3 4.1.3
Paczka npm swagger-ui-dist < 4.1.3 4.1.3
Paczka npm swagger-ui-react < 4.1.3 4.1.3
.NET (NuGet) Swashbuckle.AspNetCore.SwaggerUI < 6.3.0 6.3.0

Odnośniki

Ocena CVSS -
Słabość (CWE)
CWE-918
Platforma
npm, .NET (NuGet)
Paczka
swagger-ui, swagger-ui-dist, swagger-ui-react
Ujawniono
09.12.2021
Aktualizacja
11.10.2026 11:23

Źródła i licencje

OSV / GitHub Advisory Database - GHSA-qrmm-w75w-3wpx - CC BY 4.0

Historia podatności: swagger-ui

Wszystkie opisane podatności tej paczki (Paczka npm), od najnowszej. Widać, czy to jednorazowa wpadka, czy paczka, której trzeba pilnować.

Wszystkie (14) w archiwum
Wszystkich wpisów
14
Pierwsza → ostatnia
06.2019 05.2022
Bez poprawki
0
Wykorzystywana w atakach
0

Rozkład istotności

  • Krytyczna 4
  • Wysoka 1
  • Średnia 9

Ujawnienia w latach

  1. 2019: 2
  2. 2020: 9
  3. 2021: 1
  4. 2022: 2
  5. 2023: 0
  6. 2024: 0
  7. 2025: 0
  8. 2026: 0
Istotność:
  1. Server side request forgery in SwaggerUI ten wpis
    Średnia ghsa-qrmm-w75w-3wpx < 4.1.3 4.1.3
  2. Krytyczna ghsa-g336-c7wv-8hp3 < 2.2.1 2.2.1
  3. Wysoka CVE-2016-1000233 < 2.2.1 2.2.1
  4. Krytyczna CVE-2016-5682 < 2.2.1 2.2.1
  5. Krytyczna CVE-2016-1000226 < 2.2.1 2.2.1
  6. Krytyczna · 9.8 CVE-2019-17495 < 3.23.11 3.23.11

Dowiedz się, które podatności dotyczą Twojej aplikacji

Po podłączeniu integracji DockRay i włączeniu raportowania oprogramowania DockRay porównuje zgłoszone wersje komponentów ze znanymi podatnościami i powiadamia o potwierdzonych dopasowaniach. Zakres zależy od obsługiwanej technologii i dostępnych biuletynów.

Podłącz swoją aplikację
Newsletter DockRay

Bezpieczeństwo aplikacji w Twojej skrzynce

Najważniejsze podatności, konkretne zalecenia i praktyczne wskazówki dla Twoich aplikacji. Wybierz technologie i śledź to, co ma znaczenie dla Twojego projektu.

  • Codzienne zestawienie nowych podatności, także krytycznych.
  • Powiadomienia o ważnych aktualizacjach.
  • Praktyczne porady o bezpieczeństwie i monitoringu aplikacji.

Pozostaw puste, aby otrzymywać informacje o wszystkich technologiach.

Zapis jest bezpłatny. Wypiszesz się jednym kliknięciem w wiadomości.