Skip to content

External links with target="_blank" missing rel="noopener noreferrer" #12329

@akramcodez

Description

@akramcodez

Problem

Several templates across Open Library use anchor tags with target="_blank" but do not include the recommended rel="noopener noreferrer" attribute.

This creates a reverse tabnabbing vulnerability, where the newly opened page can access window.opener and redirect the original tab to a malicious site.

Reproducing the bug

  1. Navigate to: /account/create
  2. Scroll to the “Terms of Service” section
  3. Right-click → Inspect Element on the link
  • Expected behavior:
    The anchor tag should include security attributes:
<a class="ol-signup-form__link"
   href="//archive.org/about/terms.php"
   target="_blank"
   rel="noopener noreferrer">
   Terms of Service
</a>
  • Actual behavior:
    The anchor tag is missing the rel attribute:
<a class="ol-signup-form__link"
   href="//archive.org/about/terms.php"
   target="_blank">
   Terms of Service
</a>

Context

  • Browser (Chrome, Safari, Firefox, etc):
  • OS (Windows, Mac, etc):
  • Logged in (Y/N):
  • Environment (prod, dev, local): prod

Automated Detection

A test was added to scan templates for unsafe usage:

docker compose run --rm web pytest openlibrary/tests/test_templates.py::test_noopener_noreferrer

Result

  • ~20 failing instances detected
  • Confirms issue is widespread across templates

Affected Files (examples)

  • openlibrary/templates/account/create.html
  • openlibrary/templates/lists/lists.html
  • openlibrary/templates/lib/exports.html
  • openlibrary/templates/books/add.html
  • openlibrary/macros/AffiliateLinks.html

Impact

  • Enables reverse tabnabbing attacks
  • External pages can manipulate the original tab using window.opener
  • Considered a web security best practice violation

screenshot

Image

Metadata

Metadata

Assignees

Labels

Lead: @jimchampIssues overseen by Jim (Front-end Lead, BookNotes) [managed]Needs: BreakdownThis big issue needs a checklist or subissues to describe a breakdown of work. [managed]Needs: ResponseIssues which require feedback from leadNeeds: ReviewThis issue/PR needs to be reviewed in order to be closed or merged (see comments). [managed]Needs: TriageThis issue needs triage. The team needs to decide who should own it, what to do, by when. [managed]Theme: SecurityType: BugSomething isn't working. [managed]

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions