Problem/Motivation

https://www.drupal.org/docs/8/modules/jsonapi/security-considerations is linked in the JSON:API UI and explains how site owners can better secure their sites with JSON:API.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Per #3039568-70: Add a read-only mode to JSON:API.

Comments

Wim Leers created an issue. See original summary.

xjm’s picture

Title: Security team review of the "Security Considerations" page » Documentation review of the "Security Considerations" page
Issue summary: View changes

From @jhodgdon in #3039568-66: Add a read-only mode to JSON:API:

b) On the security page at the bottom, it says that if you use read-only mode, that "completely eliminates" security problems... but is that really true? What if reading data is a possible access violation? Maybe that sentence could be changed to say that it would eliminate security problems that could affect the content of your site.

If the page actually says that, we definitely need to remove it. That's something that should never be said of anything, ever. Assume everything has vulnerabilities, somewhere. Information disclosure is certainly still possible, and some other exploits might be able to bypass the protection of read-only mode.

Updating the title because I think others (like @jhodgdon) also have useful input here.

xjm’s picture

Issue tags: +Needs security review

There we go. :)

wim leers’s picture

I already addressed #2/@jhodgdon's point "b)" in #3039568-67: Add a read-only mode to JSON:API three days ago, i.e. in https://www.drupal.org/node/3039599/revisions/view/11339448/11340084 🙂

xjm’s picture

Hmmm I still think this is not a claim we should ever make:

This completely eliminates hypothetical, as-yet-unknown bugs in preexisting validation constraints and write logic

I would say "mitigates risks from" rather than "completely eliminates".

wim leers’s picture

Why is that not a claim we should ever make? If no writes are allowed at all, validation constraints and write logic are never executed, therefore any hypothetical vulnerabilities in them are impossible to exploit.

xjm’s picture

Regarding this header:

The importance of using stable contributed modules

I think that what's after that header applies regardless of whether or not you're using stable contrib modules. For defense in depth, auditing entity access and restricting access to unneeded resource should be recommmended even if you're using contrib also covered by the sec team. Edit: I'd give each of those things their own header, actually.

xjm’s picture

Couple other suggestions:

  1. The section on read-only mode should probably be changed to clarify that read-only mode is the default, and is recommended for any sites that don't have a need to update data over REST.
  2. Under "Bugs in entity types, field types and data types can lead to security vulnerabilities", I think there's more to it than just HTTP APIs being more easily accessible. There's three parts:
    • HTTP APIs are more easily accessible (easier to script attacks, and the same workflow in browsers will often have additional mitigations beyond what the entity and routing systems provide)
    • Drupal historically relied on form validation handling, so security research and hardening for HTTP APIs is still ongoing. (Plus the bit about needing to shift Drupal devs to an API-first mentality generally.)
    • JSON:API in particular is much more permissive to REST, link to page about its no-config DX principle, but this means that site owners need to pay more attention than they do with REST which turns on very little by default.
wim leers’s picture

#7 I agree that wasn't as clear as it should be. Fixed: https://www.drupal.org/node/3039599/revisions/view/11340084/11346954.

wim leers’s picture

RE: #5 + #6:

xjm   [2 minutes ago]
This is a general principle in security


xjm   [1 minute ago]
Never, ever claim something isn't vulnerable to something

xjm   [1 minute ago]
At most you can claim you've mitigated risks of something

wim.leers   [1 minute ago]
aight

wim.leers   [1 minute ago]
it’s still accurate though.

xjm   [1 minute ago]
No, it really isn't

wim.leers   [1 minute ago]
Why not?

xjm   [< 1 minute ago]
There's always the possibility that something bypasses whatever your API is intended to do

xjm   [< 1 minute ago]
E.g. that GET bypass in REST

xjm   [< 1 minute ago]
We didn't even think to look for it because we didn't expect it to be possible in the first place

wim.leers [< 1 minute ago]
ok

Done: https://www.drupal.org/node/3039599/revisions/view/11346954/11346984

wim leers’s picture

wim leers’s picture

greggles’s picture

More on the idea:

If no writes are allowed at all, validation constraints and write logic are never executed, therefore any hypothetical vulnerabilities in them are impossible to exploit.

I believe we've seen now 2 different RCE by anonymous where the team could only consider exploit via POST and other researchers found exploits via GET. I don't have links to the research readily at hand, but I think it's fair to say that the attack surface is greatly reduced but not completely closed.

greggles’s picture

I've just read the page - my only feedback: maybe the "internal" bullet point could link to some documentation page about what that is?

Otherwise seems great!

xjm’s picture

Thanks @greggles!

I think https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21... might be the best reference to link?

wim leers’s picture

#13: Indeed, this affected rest.module, as the chat log in #10 says. The JSON:API module didn't have this vulnerability, but I agree that it's imprudent to claim that the JSON:API module is perfectly safe, since we cannot ever assume that of any code.

#15: Yes, that'd be the best reference to link. You can update it now, or I can update it in the morning, in ~9 hours.

I'm off to sleep now. 😴

greggles’s picture

Okeydoke - added it in.

wim leers’s picture

Hah, I was just about to do that :D Thanks for updating it!

Does

Otherwise seems great!

mean we can consider this "done", or do we want to leave this open to encourage more Security Team members to review it?

greggles’s picture

I think leave open for a bit at least.

greggles’s picture

(fixing my credit, in case it matters and to default for the future)

wim leers’s picture

#19: 👍

#20: Ah yes, crediting all three of us: @xjm, @greggles and I. I will mark this Fixed once we're done here, and then we'll all be credited for our work here.

wim leers’s picture

Status: Active » Fixed

Nearly 3 weeks have passed without more replies. I think it's safe to assume no additional replies will be added.

greggles’s picture

Agreed, thanks!

wim leers’s picture

Thanks for confirming :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.