-
Notifications
You must be signed in to change notification settings - Fork 70
Closed
Labels
Description
After I login on c0d3 cli using c0d3 login
:
- print out
~/.c0d3/credentials.json
- base64 decode it. Notice that it is an object with id and token.
Looking at our mutation for creating submission, it seems like we are just decoding the cliToken
and getting the id
field to use as user's id.
Problem: So if I was a malicious user, I could simply change the id in the file and then submit as any user I want.
Here's how I would do it.
- Base64 encode:
{id: <hackedUserId>}
- Seems likecliToken
isn't even used so we don't even need that. - Paste the base64 string into
~/.c0d3/credentials.json
- Submit.
Proposal:
- In my experience, tokens should be sent in the request header. Perhaps similar to chatroom jwt auth in js5.
Bearer
Authorization type seems reasonable because bearer token meansan opaque string, not intended to have any meaning to clients using it
. - In our user middleware, check to see if user's
Authorization
Header is present. If so, lookup user by thecliToken
field, which should be indexed for fast lookups, and populatereq.user
object based on thecliToken
. - remove
cliToken
check from create submission and simply usereq.user
object.
Other thoughts
We ideally also want to remove cliToken
from createSubmission typeDef but that may break all existing c0d3 CLI.
Perhaps we could create an announcement, giving 1 week to upgrade?
Maybe we should have this issue looked into as well so we are better prepared for potential CLI breakage in the future.