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

unquote params extracted from paths #680

Closed
pjenvey opened this issue Jun 18, 2020 · 8 comments · Fixed by #748
Closed

unquote params extracted from paths #680

pjenvey opened this issue Jun 18, 2020 · 8 comments · Fixed by #748
Assignees
Labels
3 Estimate - m - This is a small change, but there's some uncertainty. bug Something isn't working p1 Stuff we gotta do before we ship!

Comments

@pjenvey
Copy link
Member

pjenvey commented Jun 18, 2020

The extractors module produces BsoParam, CollectionParam and HawkIdentifier from
extracted bits of the request path.

Our <..>_from_path methods aren't unquoting path segments. E.g. a bso_id of "{password-id}" comes in as PUT /1.5/uid/storage/passwords/%7Bpassword-id%7D: we're incorrectly considering this a bso_id of "%7Bpassword-id%7D" instead.

This likely only affects bso_ids. collection_ids are restricted to [a-zA-Z0-9._-]{1,32} and uids to [0-9]{1,10} (and we ensure uids match the hawk payload's, so there's no funny business there anyway). Whereas bso_ids allows any printable ascii character.

We've likely written garbage bso_ids via PUT. Should we attempt to fix the garbage bso_ids in the db? It would require extensive scanning of our request logs to do correctly.

DELETEs against migrated data would unexpectedly 404, causing:

https://bugzilla.mozilla.org/show_bug.cgi?id=1640123#c2

@pjenvey pjenvey added bug Something isn't working p1 Stuff we gotta do before we ship! 3 Estimate - m - This is a small change, but there's some uncertainty. labels Jun 18, 2020
@tublitzed tublitzed added this to Prioritized in Services Engineering Jun 18, 2020
@pjenvey pjenvey moved this from Prioritized to Scheduled in Services Engineering Jun 18, 2020
@jrconlin
Copy link
Member

Tempted to say we could just fix bad bso_ids on the fly when we write them back out. That would save the scan costs and let bad records expire out naturally. It does run the risk of possibly breaking any client that is expecting a bad bso_id, though.

@pjenvey
Copy link
Member Author

pjenvey commented Jun 18, 2020

The good news, according to @mhammond, is our browsers aren't going to hit this in practice.

They tend to upload records via POST instead of PUT (which completely avoids the bug). I see the crypto + meta collections do use PUT but those engines are special cases (and don't use non-alphanumeric bso_ids). passwords seems to be the only collection affected by this. The issue1640123 that found the bug was also a special case: a user running a custom script against the server.

Hence why this never occurred during QA's testing.

So we should fix this ASAP but probably don't need to worry much about garbage bso_ids.

@pjenvey
Copy link
Member Author

pjenvey commented Jun 24, 2020

Added server-syncstorage#148 as this could really use an addition to the e2e tests

@fzzzy
Copy link
Contributor

fzzzy commented Jun 25, 2020

I do think we should try scanning for garbage data, because otherwise it might just sit there forever.

@fzzzy
Copy link
Contributor

fzzzy commented Jun 25, 2020

Tempted to say we could just fix bad bso_ids on the fly when we write them back out. That would save the scan costs and let bad records expire out naturally. It does run the risk of possibly breaking any client that is expecting a bad bso_id, though.

I'm not sure those records would expire naturally. Most records don't have an expire time, right? I feel like enforcing a stricter uuid format might be better in the long run so that the uuid is always in the same format?

@jrconlin
Copy link
Member

I'm not sure those records would expire naturally. Most records don't have an expire time, right? I feel like enforcing a stricter uuid format might be better in the long run so that the uuid is always in the same format?

I'm all in favor of enforcing strict UUID formatting. I though all BSOs had some TTL associated with them. If not, we may want to consider adding one.

@tublitzed tublitzed moved this from Scheduled to Prioritized in Services Engineering Jul 13, 2020
@tublitzed tublitzed moved this from Prioritized to Scheduled in Services Engineering Jul 13, 2020
@fzzzy fzzzy moved this from Scheduled to In Progress in Services Engineering Jul 15, 2020
@fzzzy fzzzy removed their assignment Jul 23, 2020
@fzzzy
Copy link
Contributor

fzzzy commented Jul 23, 2020

I keep saying I will work on this but then I don't. I'm going to unassign myself for now.

@fzzzy fzzzy moved this from In Progress to Prioritized in Services Engineering Jul 23, 2020
@jrconlin
Copy link
Member

I can try taking a shot at this.

@jrconlin jrconlin self-assigned this Jul 23, 2020
@jrconlin jrconlin moved this from Prioritized to In Progress in Services Engineering Jul 27, 2020
jrconlin added a commit that referenced this issue Jul 28, 2020
Remove potential "{}" wrapper from bsoids and collection ids. (See original issue for details)

Test included.

Try sending in a sync request with a bso_id wrapped and URLencoded.

Closes #680
@jrconlin jrconlin moved this from In Progress to In Review in Services Engineering Jul 29, 2020
Services Engineering automation moved this from In Review to Done Aug 4, 2020
jrconlin added a commit that referenced this issue Aug 4, 2020
* bug: normalize id elements to remove potential wrap characters
* chore: Update vendored SDK to use protobuf 2.16.2

Remove potential "{}" wrapper from bsoids and collection ids. (See original issue for details)

Test included.

Try sending in a sync request with a bso_id wrapped and URLencoded.

Closes #680
@tublitzed tublitzed moved this from Done to Archived in Services Engineering Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 Estimate - m - This is a small change, but there's some uncertainty. bug Something isn't working p1 Stuff we gotta do before we ship!
Projects
3 participants