Bug 239318 - Basic authentication specified in auth popup on a website overrides subsequent API calls that requires Authorization header
Summary: Basic authentication specified in auth popup on a website overrides subsequen...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: Safari 15
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-04-13 20:02 PDT by Nikolay Latyshev
Modified: 2022-04-21 17:09 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Latyshev 2022-04-13 20:02:59 PDT
Steps to reproduce:
1. Make www.example.com protected by basic auth ("WWW-Authenticate: Basic" response header).
2. Navigate to www.example.com and enter correct credentials, e.g. admin:password.
2. Create a request to www.example.com/api/login with "Authorization: Basic" header (customer:password).

Actual result: "Authorization: Basic admin:password" header is sent to www.example.com/api/login.

Expected result: "Authorization: Basic customer:password" header is sent to www.example.com/api/login.


Use case: a website allows customer logins via sending credentials by auth header. Any non-production environment of a website protected by basic auth.
Comment 1 Nikolay Latyshev 2022-04-13 20:09:05 PDT
This is a WebKit-specific bug, works as expected in e.g. Firefox or Chrome.
Comment 2 Alexey Proskuryakov 2022-04-14 18:46:09 PDT
> 2. Create a request to www.example.com/api/login with "Authorization: Basic" header (customer:password).

Could you please clarify how this request is created? XMLHttpRequest?
Comment 3 Nikolay Latyshev 2022-04-14 19:51:45 PDT
Sorry, forgot to mention, request, in this case, should be created via Fetch API to relative URL, didn't try other options.

fetch('/api/login', {
  method: 'POST',
  body: {
    some: 'body',
  },
  headers: {
    Authorization: `Basic ${btoa(`${customer}:${password}`)}`,
})
Comment 4 Ryan Haddad 2022-04-21 17:09:39 PDT
rdar://92068426