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

Increase generated short codes entropy #491

Closed
smalot opened this issue Sep 18, 2019 · 5 comments · Fixed by #506
Closed

Increase generated short codes entropy #491

smalot opened this issue Sep 18, 2019 · 5 comments · Fixed by #506
Labels
Milestone

Comments

@smalot
Copy link

smalot commented Sep 18, 2019

Hi,

Currently the only way to increase the entropy is by using multiple docker instances.

Otherwise, you'll obtain such tokens:

  • d8Qc
  • d8QV
  • d8Qt
  • d8Q4
  • ...

So urls are quite predictible and in some cases it can result in security issue.
By increasing the length the token generator can be able to randomize more char at the same time

Like this:

  • d8QdGY
  • d8Q1vK
  • ...

Suggest env var name: SHORTCODE_MINIMUM_LENGTH (default: 4)

Many thanks

@smalot smalot added the feature label Sep 18, 2019
@acelaya
Copy link
Member

acelaya commented Sep 18, 2019

It's actually a bit more complicated than that.

At the very beginning, I implemented a logic which generates the short codes based on the id of the short URL.

It's ugly, and makes short codes to look sequential. They are also a guessable, as you noticed.

I have considered changing that several times, and I probably do it.

One option I've considered is using partial hashes (the same as git does). That would solve this problem and make them random.

I will plan this and improve it as soon as I have a spot.

@smalot
Copy link
Author

smalot commented Sep 18, 2019

I'm looking for other shorturl generator and some are able to switch between:

  • custom short url
  • incremental
  • bit.ly-style

(1) and (2) are already supported by shlink (or something like).

Indeed, it would be great to support bit.ly-style short url, with a length parameter allowing to force a minimum.

I tried to install locally the project to propose a merge request, but I'm facing some issues to make it working on my environment.

We plan to deploy a shortlinker by the end of this month. do you think you'll be able to work on it quickly ?

Many thanks for your help

@acelaya
Copy link
Member

acelaya commented Sep 18, 2019

I'm afraid end of this month is not realistic.

Even if a PR was provided, I don't think I had the time to properly review it, merge it, and prepare a release.

The tasks that will be part of next release (1.19) are already closed.

I can consider some change to prioritize this for any version after that one.

Sorry I cannot give you better news.

@acelaya acelaya mentioned this issue Sep 28, 2019
7 tasks
@acelaya acelaya added this to the 1.20.0 milestone Oct 5, 2019
@acelaya acelaya closed this as completed Oct 8, 2019
@acelaya acelaya reopened this Oct 8, 2019
@acelaya acelaya changed the title Increase entropy by specifying minimum token length Increase generated short codes entropy Oct 11, 2019
@smalot
Copy link
Author

smalot commented Oct 11, 2019

You rock !
Thanks

@acelaya
Copy link
Member

acelaya commented Nov 2, 2019

@smalot I have just released v1.20.0, which includes this feature.

In a future release I will also allow to specify the length of the shorth codes.

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

Successfully merging a pull request may close this issue.

2 participants