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

!!![TASK] Breaking: Disallow raw directive #943

Closed
wants to merge 1 commit into from

Conversation

linawolf
Copy link
Contributor

@linawolf linawolf commented Mar 17, 2024

Using the raw directive is a potencial securtiy risk.

resolves:#942
releases: main, 1.0

@linawolf linawolf requested a review from jaapio March 17, 2024 08:25
Using the raw directive is a potencial securtiy risk.

releases: main, 1.0
Comment on lines -39 to 38
/** {@inheritDoc} */
public function process(
BlockContext $blockContext,
Directive $directive,
): Node|null {
return new RawNode(implode("\n", $blockContext->getDocumentIterator()->toArray()));
public function processAction(BlockContext $blockContext, Directive $directive): void
{
$this->logger->error('The raw directive is not supported for security reasons. ', $blockContext->getLoggerInformation());
}
Copy link
Contributor

@wouterj wouterj Mar 17, 2024

Choose a reason for hiding this comment

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

I'm not 100% convinced here. I see a security issue when using reStructured Text for "user" input. For projects like the Symfony docs, where the only parsed docs are text maintained by the doc team, there is no security issue as far as I'm aware. I guess this applies to most usages of Guides.

Implementing the raw node also seems to be non-trivial. One needs to learn how to create a custom Guides extension and how to create a custom directive.

If we want this, I think we should do 2 things:

  • Be more explicit about the security issue the raw node causes, so users can make informed decisions.
  • Add a config option to disable the raw node, like docutils also has.

We then have to think about the default, docutils defaults to true which we might want to follow for compatibility reasons. Or we can decide to default to false if we think the security issues are common enough to protect users against.

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 not remove this directive from the code base but allow a config option to enable it. Or log the error when disabled. By making it an option people could still overwrite the behavior using configuration. but this could be enforced by a listener in an extension to ensure people cannot overwrite the configuration.

The security risk here is on the typo3 side, as the documentation is published on their website, but maintained by approved third-party developers.

Copy link
Contributor

@wouterj wouterj Mar 20, 2024

Choose a reason for hiding this comment

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

The security risk here is on the typo3 side, as the documentation is published on their website, but maintained by approved third-party developers.

We have a similar situation for some community bundles where we render their docs in https://symfony.com/bundles, but we need the raw directive for the main Symfony docs. So a config option would be useful for us, we render the bundles section separately from the main docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think when you have to use the raw directive that means, that there is something missing in your pipline. It is also very hard to change such HTML output automatically lateron. So I would rather suggest to write specialized directives for your use cases...

@linawolf linawolf self-assigned this Mar 18, 2024
@linawolf
Copy link
Contributor Author

I will make another PR

@linawolf linawolf closed this Mar 23, 2024
@jaapio jaapio deleted the task/raw-directive branch March 26, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants