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

fix: Escape user-supplied strings in URLs to prevent injection #211

Closed
wants to merge 1 commit into from

Conversation

LewisW
Copy link
Contributor

@LewisW LewisW commented Jun 10, 2024

Change Summary

Fixes #194 by escaping user-supplied strings in URLs. This fixes a potential vulnerability that gives a malicious actor the ability to delete parent collections by starting their ID with a hash (in cases where something user-supplied like a username, email etc. is used for the document ID/prefix).

It's also pretty common practice to use the # character in dynamodb keys, which is how we discovered this issue.

PR Checklist

Copy link
Member

@jasonbosco jasonbosco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @LewisW.

To ensure that this doesn't break for existing users who might be URL encoding entity names / IDs themselves before passing them to Typesense, could you add a boolean configuration option when instantiating the library, called say urlEncodeEntityIDs: true | false and only URL encode when this flag is enabled?

@kopertop
Copy link
Contributor

Just to add a +1 here, this also breaks when IDs have a / in them.

I would suggest the default should be to do the URL encoding in the library, and if you need an explicit opt-out for backwards compatibility you could add that, but certainly the default should be to encode them in the library (for new users like myself).

phiHero added a commit to phiHero/typesense-js that referenced this pull request Aug 27, 2024
jasonbosco added a commit that referenced this pull request Aug 29, 2024
Resolve conflicts for #211 (fix: Escape user-supplied strings in URLs to prevent injection)
@jasonbosco
Copy link
Member

Thank you for the PR. We've moved the commits from this PR #226 to resolve conflicts and merged that PR in.

@jasonbosco jasonbosco closed this Aug 29, 2024
tharropoulos pushed a commit to tharropoulos/typesense-js that referenced this pull request Sep 5, 2024
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

Successfully merging this pull request may close these issues.

Deleting collections with special characters doesn't work
3 participants