Skip to content

Security risk: Auth tokens tied to OPDS Authentitcation Document Id can be exploited by attackers #83

Open
@mpdunlop

Description

@mpdunlop

While discussing an issue relating to OPDS Authentication it was mentioned that OPDS Clients should be storing authorization tokens against the id of the OPDS Authentication Document.

Tying authentication tokens to the id of the OPDS Authentication Document has security considerations. An attacker wanting to gain access to a user's account could craft an OPDS Publication Feed that requires authentication and return an OPDS Authentication Document that uses the same id as a legitimate OPDS Feed provider. If the user has previously authenticated using that document, and the OPDS Client looks up the auth token by the document's id, it will select a valid token and send it to the attacker.

  1. https://opds.contoso.org/publications.json requires authentication, first access returns OPDS Authentication Document with id https://auth.contoso.org/odps-auth.json
  2. User signs in and accesses their feed successfully
  3. Some time later, the user is later coerced into loading feed from attacker's domain (e.g. https://opds.contosoo.org/publications.json, a domain similar in appearance to an authentic one which is common in scams).
  4. The attacker has set this feed up to also requires authentication, and upon the OPDS Client first accessing it, it returns an OPDS Authentication Document with the same id as a legitimate OPDS provider, e.g. https://auth.contoso.org/odps-auth.json
  5. As the malicious authentication document's id matches the previously seen authentication document's id, the OPDS Client will use the authorization token issued previously and attempt to re-fetch the publication with the authorization token previously issued for the real contoso.org. This last step is the OPDS client leaking the valid token to the attacker.

OPDS Clients must not provide the token in this scenario. In the case of Basic Auth, this could result in usernames and passwords being entered by users and shared with the attacker. For OAuth, the access_token would be shared with the attacker.

In the short-term, OPDS clients who use the id field to cache authorization tokens should perform validation on the Authentication Document's Id (which the spec already defines as the canonical location for the Authentication Document) to ensure that it matches the address the authentication document is being served from. Failure to do so may result in user details being leaked to bad actors.

This may also have implications for the discussion in #43

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions