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

Circular Links Not Blocked – Causes Infinite Redirects #2053

Open
Zingzy opened this issue Feb 20, 2025 · 2 comments
Open

Circular Links Not Blocked – Causes Infinite Redirects #2053

Zingzy opened this issue Feb 20, 2025 · 2 comments

Comments

@Zingzy
Copy link

Zingzy commented Feb 20, 2025

Currently, the platform allows users to create short links that redirect to themselves, leading to an infinite redirection loop when accessed. This can cause usability issues and excessive browser resource consumption.

Steps to Reproduce

  1. Go to Dub.co or a self-hosted instance.
  2. Create a new short link with a custom alias, e.g., mytestlink.
  3. Set the destination URL as the same short link: https://dub.co/mytestlink.
  4. Click "Create" and then access the generated link.
  5. The browser enters an infinite redirection loop.
Recording.2025-02-20.141313.1.mp4

Expected Behavior

  • The system should detect circular references and prevent users from creating short links that redirect to themselves.
  • The user should see an appropriate error message such as:
    "You cannot shorten a link that redirects to itself."
  • The link should not be stored in the database.

Impact

  • User Experience Issue: Infinite redirects can cause browser crashes.
  • SEO Concerns: Search engines might flag the site for improper redirections.
  • Potential Exploits: Users might misuse this for phishing attacks or abuse.
  • Performance Overhead: Unnecessary redirects increase server load.
  • Browser Stability Issues: Some browsers do not handle infinite redirects well and may crash, leading to a poor user experience for end users.

Proposed Solution

I would add a new check in apps/web/lib/api/links/process-link.ts, specifically in the processLink function, to detect circular URLs and return a proper error message before storing the link.

Would this be the right place to implement the fix, or would you recommend another approach?

If this issue is validated, I would be happy to submit a pull request with a fix. Let me know if this change is necessary, and I will proceed accordingly.

Copy link

linear bot commented Feb 20, 2025

@AbhiArya20
Copy link

@Zingzy

I am also interested in this issue. Can we discuss the approach to solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants