jaothan commited on
Commit
58d838c
·
verified ·
1 Parent(s): 88fed60

Upload 5 files

Browse files
Files changed (5) hide show
  1. Dockerfile +21 -0
  2. Introduction.py +58 -0
  3. docker-compose.yml +12 -0
  4. requirements.txt +8 -0
  5. setup.cfg +5 -0
Dockerfile ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt /
6
+ RUN pip install -r /requirements.txt
7
+
8
+ RUN useradd -m -u 1000 user
9
+
10
+ USER user
11
+
12
+ ENV HOME=/home/user
13
+ ENV PATH=/home/user/.local/bin:$PATH
14
+
15
+ WORKDIR $HOME/app
16
+
17
+ COPY --chown=user . $HOME/app
18
+
19
+ EXPOSE 8050
20
+
21
+ CMD ["streamlit", "run", "Introduction.py"]
Introduction.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ from modules.utils import set_sidebar
4
+
5
+
6
+ def main():
7
+ st.set_page_config(
8
+ page_title="AMLD SQL Injection Demo",
9
+ page_icon="assets/effixis_logo.ico",
10
+ layout="centered",
11
+ )
12
+ set_sidebar()
13
+ st.title("SQL Injections via LLMs")
14
+ st.markdown("### *Welcome to Effixis' demo for AMLD EPFL 2024!* 🎉")
15
+
16
+ st.markdown(
17
+ """
18
+ #### What is this demo about?
19
+ This demo is about risk associated with the use of LLMs, in this case illustrated by SQL injections.
20
+ SQL injections are a common vulnerability in web applications.
21
+ They allow an attacker to execute arbitrary SQL code on the database server.
22
+ This a very dangerous vulnerability as it can lead to data leaks, data corruption, and even data loss.
23
+
24
+ #### The SQL database used in this demo
25
+ The database used in this demo is the Chinook database.
26
+ It is a sample database that represents a digital media store, including tables for artists, albums, media tracks, invoices, and customers.
27
+
28
+ You can see the schema below:
29
+ """
30
+ )
31
+ st.image("assets/chinook.png")
32
+
33
+ st.markdown(
34
+ """
35
+ #### What do LLMs have to do with this?
36
+ A large use case for large language models (LLM) is to generate SQL queries.
37
+ This is a very useful feature, as it allows users to interact with databases without having to know SQL.
38
+ But this is also prone to SQL injections, as the users can maliciously propt the LLM to generate harmful SQL queries.
39
+ """
40
+ )
41
+
42
+ st.divider()
43
+ st.markdown(
44
+ """
45
+ #### The Levels
46
+ Try to inject malicious SQL code to alter the SQL table, each level is more difficult than the previous one!
47
+
48
+ - **Level 1**: You generate the SQL queries with the help of the LLM.
49
+ - **Level 2**: The SQL queries are first checked by an LLM Safeguard, which detects and removes malicious SQL queries.
50
+ - **Level 3**: The only difference with Level 2 is that we are using a better LLM model, GPT-4, for the safeguard.
51
+
52
+ Are you happy with your results? Submit the keys on the leaderboard to see how you compare to others!
53
+ """
54
+ )
55
+
56
+
57
+ if __name__ == "__main__":
58
+ main()
docker-compose.yml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: "3.9"
2
+
3
+ services:
4
+ backend:
5
+ restart: "no"
6
+ build:
7
+ context: .
8
+ dockerfile: Dockerfile
9
+ ports:
10
+ - 8050:8050
11
+ env_file:
12
+ - .env
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ langchain==0.1.12
2
+ langchain-community==0.0.28
3
+ langchain-core==0.1.32
4
+ langchain-openai==0.0.8
5
+ openai==1.14.1
6
+ python-dotenv==1.0.1
7
+ SQLAlchemy==2.0.28
8
+ streamlit==1.32.2
setup.cfg ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#:~:text=Line%20length,-You%20probably%20noticed&text=Black%20defaults%20to%2088%20characters,used%20by%20the%20standard%20library).
2
+ [flake8]
3
+ max-line-length = 88
4
+ select = C,E,F,W,B,B950
5
+ extend-ignore = E501, E203, W503