Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Do you need to sign a Relay pagination cursor?

Before starting the main topic I would like to clarify that in this article when I say: Encoding (base64, MessagePack), it means change the format only. But anyone can reverse it, there is no secret. Signing (here HMAC with a secret), it means letting the server to detect a cursor that was edited or forged. But we are not not trying to hide the content. TL;DR No . The Relay Cursor Connections…

The Relay Cursor Connections specification never requires a signed cursor. It simply states that a cursor represents an item's position in a list. Each edge has an opaque cursor, which does not reveal any information about the contents. The spec does not mandate encryption or tying the cursor to the query that issued it. The cursor is just an opaque string meant to be unreadable by the client.

In NodeJS/NestJS, developers used to encode and sign every cursor to add security. For example, a cursor might look like "eyJhIjoiTVMyWVo3Wkl5WkZSMW1fM1FkaHhubSIsImsiOlsiMWM3NjJlMTgtNzZiMS00YWU4LTg1ZjctZWRmYmUzMjAxODBmIl19.KZX-ximd3leLM_1k0SXAPxZjaysKAvHzEcMrGf3-Tjk". This cursor is a combination of a base64url-encoded JSON payload and a base64url-encoded HMAC-SHA256 signature.

The payload contains the cursor's key-value pairs: k (position of the cursor) and a (audience, identifying the query). The signature ensures that the cursor cannot be forged or edited. However, anyone can still reverse the encoding and view the contents of the payload.

Switching to the Ent framework, signed cursors were dropped in favor of unsigned cursors. These unsigned cursors are MessagePack, base64-encoded and contain the row's ID and sort value. For instance, the cursor "gqFpxBD9fOCeg+NNroyEqHImBq4uoXajWlpa" holds the novel ID and the value of the field the list is ordered by. Since there is no signature, anyone can decode, edit, and re-encode the cursor.

This poses no significant security risk, as the server applies the query's filters and permissions regardless. The cursor's generation in Ent is handled through the `entgql.Cursor[uuid.UUID]` type.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Show Ties Honestly in a CaptchaTheCat Scorecard

If I use a public CaptchaTheCat comparison as a starting point for a scorecard, I want to know what it means when two rows show the same number. Two estimates may be exactly equal under the metric.

  • CaptchaTheCat scorecard compares rows with same figures
  • Metric population and date range displayed with score
  • Empty observation window marked as evidence gap

Model each USB-C charger port configuration in a JavaScript table

AI-generated worked example, checked by executing the JavaScript. Charger allocations below are fictional. A charger can advertise 100 W in total while allocating 65 W to a laptop port in one…

  • JavaScript code models USB-C charger port configurations in a table format
  • Calculates total cable wattage as 100 W (20 V x 5 A) and device wattage as 65 W

More from Tuesday 24 November →