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

MSC2398: proposal to allow mxc:// in the "a" tag within messages #2398

Open
wants to merge 1 commit into
base: old_master
Choose a base branch
from

Conversation

eras
Copy link

@eras eras commented Jan 2, 2020

Currently message events (m.room.message) can contain formatted data in its formatted_body field, if the format of the message is org.matrix.custom.html. This is a proposal to allow the mxc:// schema to appear also for a tags in addition to just img tags currently permitted (in fact, required).

Rendered: https://github.com/eras/matrix-doc/blob/MSC2398-mxc-for-a-tags/proposals/2398-allow-mxc-within-message-links.md


SCT:

Implementation: Not required. Feature appears to be self-contained enough to make sense as-is. ~TravisR

FCP tickyboxes

Copy link
Member

@KitsuneRal KitsuneRal left a comment

Choose a reason for hiding this comment

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

Since mxc:// is effectively a proxy scheme to https://<media-api-path>/download, this looks like a very good way to refer to content residing on Matrix media servers. The alternative, actually, does exist: to use the HTTP(S) /download URL, which is by definition inferior to this proposal.

@turt2live turt2live added proposal A matrix spec change proposal proposal-in-review labels Jan 2, 2020
@turt2live
Copy link
Member

@eras also slightly annoying, but the proposal needs to be signed off so we can merge it: https://github.com/matrix-org/matrix-doc/blob/master/CONTRIBUTING.rst#sign-off

@eras eras force-pushed the MSC2398-mxc-for-a-tags branch from f320313 to 3ce4ef8 Compare January 3, 2020 06:12
Signed-off-by: Erkki Seppälä <flux@modeemi.fi>
@eras eras force-pushed the MSC2398-mxc-for-a-tags branch from 3ce4ef8 to 85eb356 Compare January 3, 2020 06:20
@eras
Copy link
Author

eras commented Jan 3, 2020

Updated.

Changes:

  • Added note about alternatives per @KitsuneRal 's comment
  • Removed changes to instant_messaging.rst per @turt2live 's comment
  • Added a Signed Off -line to the commit message per @turt2live 's comment

Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

Thanks! The proposal itself looks very sane.

@turt2live turt2live added the kind:maintenance MSC which clarifies/updates existing spec label Apr 20, 2020
@turt2live turt2live added the needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. label Jun 8, 2021
@eras
Copy link
Author

eras commented Feb 13, 2022

So it came to me that an implementation should be careful when implementing this.

In particular, when a web-based client opens a HTML document from the same domain as the Matrix API, the document can probably use JavaScript to make requests with the user's credentials.

@ShadowJonathan
Copy link
Contributor

@eras i believe those thoughts would be best served under the "Security Considerations" header in the proposal 👍

Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

non-blocking concerns


## Proposal

The spec for `a` tags says:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The spec for `a` tags says:
The spec for `a` tags [says](https://spec.matrix.org/v1.8/client-server-api/#mroommessage-msgtypes):

@turt2live
Copy link
Member

sorry this got stuck :(

@mscbot fcp merge

@mscbot
Copy link
Collaborator

mscbot commented Nov 14, 2023

Team member @mscbot has proposed to merge this. The next step is review by the rest of the tagged people:

Concerns:

  • add explicit text about transforming mxc link to https
  • How do you implement this on web clients with MSC3916

Once at least 75% of reviewers approve (and there are no outstanding concerns), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for information about what commands tagged team members can give me.

@mscbot mscbot added proposed-final-comment-period Currently awaiting signoff of a majority of team members in order to enter the final comment period. disposition-merge labels Nov 14, 2023
@turt2live turt2live removed the needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. label Nov 14, 2023
Copy link
Member

@dbkr dbkr left a comment

Choose a reason for hiding this comment

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

Going to raise a concern for adding the bit about transforming the mxc link just so there's a clear action point, but just to say that in spite of this and the grammar nitpicks, this is a superbly written and simple, but thorough, MSC, and in general seems like a great change. Thank you!

# MSC2398: Proposal to allow mxc:// in the `a` tag within messages

Currently message events (m.room.message) can contain formatted data
in its formatted_body field, if the format of the message is
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
in its formatted_body field, if the format of the message is
in their formatted_body field, if the format of the message is


Currently message events (m.room.message) can contain formatted data
in its formatted_body field, if the format of the message is
org.matrix.custom.html. In this subset of HTML `img` tags are permitted
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
org.matrix.custom.html. In this subset of HTML `img` tags are permitted
org.matrix.custom.html. In this subset of HTML, `img` tags are permitted

in its formatted_body field, if the format of the message is
org.matrix.custom.html. In this subset of HTML `img` tags are permitted
if they refer to media repository contents with the mxc schema and
clients are able to resolve these URIs to (ie.) HTTPs to retrieve the
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
clients are able to resolve these URIs to (ie.) HTTPs to retrieve the
clients are able to resolve these URIs to (eg.) HTTP(s) URLs to retrieve the

Sorry if these feel nitpicky, I'm just having to re-read a couple of times to work out what the MSC is saying so attempting to clarify.

-`a`:
`name`, `target`, `href` (provided the value is not relative and has a scheme
matching one of: `https`, `http`, `ftp`, `mailto`, `magnet`, or `mxc`
for `Matrix Content (MXC) URI`)
Copy link
Member

Choose a reason for hiding this comment

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

Much as it's obvious, presumably the spec would also need to explicitly say that the client must transform the mxc link into an appropriate link the browser will understand (ie. what you talk about above with img tags).

Copy link
Member

Choose a reason for hiding this comment

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

This feels like something which is best served by a note rather than requirement. Web clients will probably need to convert it, but other clients might be able to handle a custom scheme for network requests.

I'd suggest that this not be a blocking concern for FCP, as the spec text can provide guidance on how to handle it.

Copy link
Member

Choose a reason for hiding this comment

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

I would really prefer the MSC say explicitly that clients should manage this scheme in one way or another - ultimately a custom handler will have to translate the mxc URL into an HTTP(S) request anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Oh wait but isn't "Clients would be able to handle the mxc schema here in the exact same way they handle img tags" above exactly this description, actually? I personally think that is enough.

Copy link
Member

Choose a reason for hiding this comment

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

What do you think @dbkr?

Copy link
Member

Choose a reason for hiding this comment

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

I guess it just seemed odd to me that an explicit change to the spec text was given but then additional behaviour specified in the MSC. I suppose it's all there though so it doesn't really matter.

@dbkr
Copy link
Member

dbkr commented Nov 28, 2023

@mscbot concern add explicit text about transforming mxc link to https

@mscbot mscbot added the unresolved-concerns This proposal has at least one outstanding concern label Nov 28, 2023
@dbkr
Copy link
Member

dbkr commented Jan 9, 2024

@mscbot resolve add explicit text about transforming mxc link to https

@mscbot mscbot removed the unresolved-concerns This proposal has at least one outstanding concern label Jan 9, 2024
retrieve resources linked this way. Some clients may already
accidentally support this, though, due to consistent handling of URIs.

## Security considerations ##
Copy link
Member

Choose a reason for hiding this comment

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

It's probably worth spelling out explicitly here that the security risks of linking directly to content in the repository is not just HTML, but any format which can execute code and potentially XSS needs to be mitigated by a valid CSP - e.g. JS, PDF, SWF, SVG. This isn't anything new, but it's still a security consideration. I can't think of a world where a HTTPS url derived from an MXC URL wouldn't be subject to CSP when a plain HTTPS url to the same content would, but still worth spelling it out at least in the MSC, if not the final spec.

@mscbot
Copy link
Collaborator

mscbot commented Jan 12, 2024

🔔 This is now entering its final comment period, as per the review above. 🔔

@mscbot mscbot added final-comment-period This MSC has entered a final comment period in interest to approval, postpone, or delete in 5 days. and removed proposed-final-comment-period Currently awaiting signoff of a majority of team members in order to enter the final comment period. labels Jan 12, 2024
@@ -0,0 +1,55 @@
# MSC2398: Proposal to allow mxc:// in the `a` tag within messages
Copy link
Member

Choose a reason for hiding this comment

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

How does this proposal interact with MSC3916, which basically adds authentication to the media API? I assume if we can make it work for img tags we can make it work for a, but I think that needs to be verified.

Copy link
Member

Choose a reason for hiding this comment

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

The media ID would be attributed to a single event somewhere, and clients would be translating mxc:// to https:// for the user. This then behaves no differently than if a user were to get linked to the download endpoint directly - authentication would be required, and if that user can't see the original event then the link is broken for that user.

Copy link
Member

Choose a reason for hiding this comment

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

This then behaves no differently than if a user were to get linked to the download endpoint directly - authentication would be required, and if that user can't see the original event then the link is broken for that user.

But getting linked directly to the download endpoint won't work, as there is no way for a user to authenticate AIUI? I thought for media web clients would potentially need to download the media in service workers or whatever to make the authentication work, in a similar manner as today to make encrypted attachments work. Is that method viable here?

Copy link
Member

Choose a reason for hiding this comment

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

A service worker would be required, which should be workable. The client can essentially iframe it and append the appropriate headers. This then ties into Matthew's comment about security considerations: #2398 (comment)

I'm tempted to suggest a blocking concern on this as it feels valuable to test/implement, particularly while MSC3916 and friends are being experimented with. It's akin to custom emoji/stickers where I think we want to avoid making the problem worse short-term if we can avoid it.

@erikjohnston
Copy link
Member

@mscbot concern How do you implement this on web clients with MSC3916

Sorry, but sounds like we need to double check the above before we can land this. Hopefully someone can just confirm its possible. c.f. #2398 (comment)

@mscbot mscbot added the unresolved-concerns This proposal has at least one outstanding concern label Jan 15, 2024
@mscbot
Copy link
Collaborator

mscbot commented Jan 17, 2024

The final comment period, with a disposition to merge, as per the review above, is now complete.

@mscbot mscbot added finished-final-comment-period and removed disposition-merge final-comment-period This MSC has entered a final comment period in interest to approval, postpone, or delete in 5 days. labels Jan 17, 2024
@turt2live
Copy link
Member

(FCP is not complete because there are outstanding concerns - see matrix-org/mscbot-python#3 )

@turt2live turt2live added the blocked Something needs to be done before action can be taken on this PR/issue. label Jan 18, 2024
KitsuneRal added a commit to quotient-im/Quaternion that referenced this pull request Feb 18, 2024
@turt2live
Copy link
Member

The outstanding concern on this does not appear easily resolved - I'm cancelling FCP or returning this MSC back to its pre-FCP state (whichever the bot lets me do) pending further work in the area of media linking. It feels like changes may be required that would warrant a new FCP call anyways.

@mscbot fcp cancel

@mscbot
Copy link
Collaborator

mscbot commented Mar 26, 2024

This proposal is not in FCP nor has had FCP proposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Something needs to be done before action can be taken on this PR/issue. kind:maintenance MSC which clarifies/updates existing spec proposal A matrix spec change proposal proposal-in-review unresolved-concerns This proposal has at least one outstanding concern
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants