SKY-D358 · Security in code
Gradio app open on every network interface without a login
Gradio is a Python library for putting a web page in front of a model or function; launch() starts its web server. SKY-D358 reports a launch() that binds to every network interface (server_name of "0.0.0.0" or "::") without setting auth or auth_dependency.
- Languages
- Python
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- Public Gradio launch without configured auth
Why it matters
Anyone who can reach the machine's address can use the app: run the model on your bill, read whatever the tool can read, and call the app's HTTP API directly. Demo apps often wrap internal data or paid model calls and are then left running on a cloud server.
What Skylos flags
import gradio as gr from support.agent import answer_ticket def respond(message, history): return answer_ticket(message, history) demo = gr.ChatInterface(respond, title="Support assistant") if __name__ == "__main__": demo.launch(server_name="0.0.0.0", server_port=7860)What Skylos leaves alone
import gradio as gr from support.agent import answer_ticket def respond(message, history): return answer_ticket(message, history) demo = gr.ChatInterface(respond, title="Support assistant") if __name__ == "__main__": demo.launch(server_name="127.0.0.1", server_port=7860)Why Skylos leaves it alone
127.0.0.1 is the loopback address: only programs on the same machine, such as a reverse proxy that does the login, can connect. Only the all-interfaces addresses are reported.
How Skylos decides
- Runs with
--dangeron Python files. Finds.launch()calls on an object made bygradio.Blocks(),gradio.Interface()orgradio.ChatInterface(): called directly, through a variable, or bound bywith gr.Blocks() as demo:. - Reads the keyword arguments, including those spread from a dictionary with
**optionswhen every key of that dictionary is a fixed string. When a variable can hold several values (a list in a loop, or differentifbranches), each visible combination is checked. - Reports HIGH when
server_namecan be the literal"0.0.0.0","::"or"[::]", no keyword set is unknown, andauthandauth_dependencyare both missing or set toNone. Any other value ofauthcounts as configured.
How to fix it
Require a login with auth, taking the user name and password from the environment or a secret store, or pass an auth_dependency that checks your own single sign-on. If only one machine needs the app, bind to 127.0.0.1 instead.
Added: import osAdded: import gradio as gr from support.agent import answer_ticket def respond(message, history): return answer_ticket(message, history) demo = gr.ChatInterface(respond, title="Support assistant") if __name__ == "__main__":Removed: demo.launch(server_name="0.0.0.0", server_port=7860)Added: demo.launch(Added: server_name="0.0.0.0",Added: server_port=7860,Added: auth=(os.environ["SUPPORT_UI_USER"], os.environ["SUPPORT_UI_PASSWORD"]),Added: )When it can be wrong
- An app in a container must bind to
0.0.0.0for port mapping to work. When the container is only reachable through a proxy that does the login, the finding is a false alarm. - Any
authvalue other thanNonecounts as configured, even a function that accepts every password. - Missed:
share=True(which publishes the app on a publicgradio.livelink), a host read at run time such asos.environ.get("HOST", "0.0.0.0"), theGRADIO_SERVER_NAMEenvironment variable, chained calls such asdemo.queue().launch(server_name="0.0.0.0"), and options passed as**kwargswhose keys Skylos cannot see.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Mark the
launch(line when a proxy in front of the app requires a login, and say which.Python demo.launch(server_name="0.0.0.0") # skylos: ignore[SKY-D358] behind SSO proxyskylos baseline ., then--baseline, accepts existing launches by file and line.[tool.skylos] ignore = ["SKY-D358"]turns the rule off for the whole project.