Based on my experience, achieving advanced formatting in a Streamlit app is possible when the allow_unsafe_html tag is set to True, which could potentially lead to security problems and vulnerabilities.
However, what if the Streamlit app is hosted on a server where encryption and other security aspects are managed? For instance, through NGINX configuration, the site employs Let’s Encrypt, and all user inputs are sanitized.
As I am relatively new to this topic, I am eager to understand under what circumstances we can allow unsafe HTML, provided that the site is protected through other tools (such as NGINX configuration, Let’s Encrypt, firewall settings, user input sanitation).
I would greatly appreciate detailed insights on these aspects. The reason being, I’d like my Streamlit app to adhere to ISO 27000 standards while still utilizing more advanced styling elements. OS: AlmaLinux 9
That is a very broad and complex topic. What makes you think that our answers here would help you to comply with 27k standards? What do they say about rendering user-provided HTML?
My firewall and Nginx, along with input sanitization, take care of most vulnerabilities. I’m not an expert in security, and I don’t aim to fulfill every ISO27K requirement. I will try to ask more concrete questions through examples.
Can the current security headers prevent attacks in this scenario?
Overall, I would like to know if the current Nginx headers allow me to safely add customized CSS styles to my page. I don’t plan to add JavaScript functions or anything similar. With regular security scans on the server I ensures the security by the way.
I hope my questions are clear. Thank you for your assistance.
I am not really familiar with HTTP headers and I am far from being an expert too. That said, I don’t think any of your examples pose an XSS risk by itself, since no untrusted content is involved.
The issue with, let’s say, your example 3 is that, at a later time, somebody may change hide_streamlit_style from a hardcoded string to a dynamically generated one, without realizing the security implications of doing that.
Thanks! It would be helpful to read an article about best practices for using the unsafe_allow_html tag safely, with examples. Specifically, it would be great to understand what it can and cannot do, how to use it for CSS styling, and any other relevant guidelines.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.