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

Removal of inline scripts to make it easier to implement strict CSP against XSS attacks #1122

Open
LDSamson opened this issue Oct 9, 2024 · 1 comment

Comments

@LDSamson
Copy link

LDSamson commented Oct 9, 2024

For example, every bslib::card() will create some inline javascript, calling bslib.Card.initializeAllCards() (see below). Would it be possible to move this function call to an external JS file and calling it with something like <script src=''></script> instead?

Removing as many inline scripts as possible would make it easier to set a strict Content Security Policy when serving a shiny application, and setting such a policy greatly improves security against XSS attacks. I am not sure if this is possible, but I thought it is worth a try to ask.

cat(format(bslib::card()))
<div class="card bslib-card bslib-mb-spacing html-fill-item html-fill-container" data-bslib-card-init data-require-bs-caller="card()" data-require-bs-version="5">
  <script data-bslib-card-init>bslib.Card.initializeAllCards();</script>
</div>
@gadenbuie
Copy link
Member

gadenbuie commented Oct 9, 2024

There are a few other options we've explored, with the top candidate being rewriting cards and sidebars as Custom Elements or Web Components. If we were implementing them again today, this would certainly be our first choice. Some work has been done in this direction in #1009, but unfortunately we haven't had the time to take this on. It's definitely on our radar and we appreciate you bringing it up!

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

No branches or pull requests

2 participants