{"id":18889775,"url":"https://github.com/scottlogic/prompt-injection","last_synced_at":"2025-04-14T23:30:59.124Z","repository":{"id":179465487,"uuid":"663480434","full_name":"ScottLogic/prompt-injection","owner":"ScottLogic","description":"Application which investigates defensive measures against prompt injection attacks on an LLM, with a focus on the exposure of external tools.","archived":false,"fork":false,"pushed_at":"2024-05-03T15:01:50.000Z","size":34659,"stargazers_count":11,"open_issues_count":71,"forks_count":8,"subscribers_count":3,"default_branch":"dev","last_synced_at":"2024-05-18T03:48:22.099Z","etag":null,"topics":["sl-classification-confidential","sl-owner-gsproston","sl-status-active"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ScottLogic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-07T11:44:43.000Z","updated_at":"2024-07-05T15:45:56.477Z","dependencies_parsed_at":"2024-04-15T11:56:55.566Z","dependency_job_id":"30f35c87-a117-4b93-91e4-b88bded6df26","html_url":"https://github.com/ScottLogic/prompt-injection","commit_stats":null,"previous_names":["gsproston-scottlogic/prompt-injection","scottlogic/prompt-injection"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fprompt-injection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fprompt-injection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fprompt-injection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fprompt-injection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScottLogic","download_url":"https://codeload.github.com/ScottLogic/prompt-injection/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248978486,"owners_count":21192799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sl-classification-confidential","sl-owner-gsproston","sl-status-active"],"created_at":"2024-11-08T07:50:52.451Z","updated_at":"2025-04-14T23:30:58.343Z","avatar_url":"https://github.com/ScottLogic.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![SpyLogic Avatar](./frontend/src/assets/images/BotAvatarDefault.svg) Welcome to SpyLogic\n\n## Introduction\n\nWelcome to the open source Scott Logic prompt injection playground!\n\nAs generative AI and LLMs are becoming more prevalent, it is important to learn about the weaknesses inherent to\ngenerative AI models. We have built an application called **SpyLogic** to teach people in a fun way about prompt\ninjection attacks, and how to defend against them.\n\nSpyLogic is presented in two modes:\n\n### Story mode\n\nGo undercover and use prompt injection attacks on ScottBrewBot, a clever but flawed generative AI bot. Extract company\nsecrets from the AI to progress through the levels, all the while learning about LLMs, prompt injection, and defensive\nmeasures.\n\n### Sandbox mode\n\nActivate and configure a number of different prompt injection defence measures to create your own security system. Then\ntalk to the AI and try to crack it!\n\n## OpenAI\n\nThis app is build using the OpenAI API. To use it you will need to have an [OpenAI](https://openai.com/) account, and that account must have credit! You can check your credit on the [billing page](https://platform.openai.com/account/billing/overview).\n\n$5 of credit is issued to every new free acount, however this expires after 3 months ([true in July 2023](https://community.openai.com/t/does-even-today-openai-provides-free-api-credits/289938)). Note: When you verify a new account, you do so with a phone number. To gain free credits, you will need to use a phone number that has not yet verified an account. See [OpenAI Pricing](https://openai.com/pricing) for more information.\n\n## Installation\n\nMinimum requirement: Node v18\n\n```bash\nnpm ci\n```\n\n## Setup Local Environment\n\nTo run locally, a few environment variables must be defined. We are using [dotenv](https://github.com/motdotla/dotenv)\nto load local `.env` files.\n\n_Note: these files are deliberately gitignored, as they will contain secrets! Never commit them._\n\n### API\n\n1. In the backend directory, copy file [.env.example](backend/.env.example) and name the copy `.env`, then open for\n   editing\n2. Set value of `OPENAI_API_KEY` to your [OpenAI API key](https://platform.openai.com/account/api-keys)\n3. Set value of `SESSION_SECRET` to a [random UUID](https://www.uuidgenerator.net/)\n\n### UI\n\n1. In the frontend directory, copy file [.env.example](frontend/.env.example) and name the copy `.env`\n2. If you've changed the default port for running the server, modify the value of `VITE_BACKEND_URL` accordingly\n\n## Run\n\n### Local\n\nIt is easiest to host both API and UI through the server. From project root:\n\n```bash\nnpm run build\nnpm start\n```\n\nAlternatively, to run in Docker we have provided a [Compose file](./compose.yaml) and npm scripts for convenience:\n\n```bash\n# Run container - image will be built first time this is run, so be patient\nnpm run docker:start\n\n# Tail the server logs\nnpm run docker:logs\n\n# Stop the container\nnpm run docker:stop\n```\n\nIn either case you will need the `backend/.env` file, as mentioned above.\n\n### Remote\n\nFor those wishing to host the application in their own infrastructure, we have provided two Dockerfiles:\n\n1. [Dockerfile](./backend/Dockerfile) in the backend directory will generate an image for running just the API. If you\n   intend to deploy to the cloud, this is the one to use.\n2. [prodlite.Dockerfile](./prodlite.Dockerfile) in the root directory will generate an image hosting UI and API from the\n   same server, for convenience. This will get you up and running as quickly as possible.\n\nIn either case, you will need to provide environment vars `OPENAI_API_KEY` and `SESSION_SECRET` (as described in\n[Setup Environment](#setup-local-environment) above).\n\nPlease note server-side session storage is currently in-memory, so if you wish to scale the API you will either need to\nenable sticky load-balancing, or, modify the code to use a shared storage solution - refer to\n[Express-Session](https://www.npmjs.com/package/express-session#compatible-session-stores) for the various options.\n\n## Develop\n\nFor all the hot reloading and React DevTools comforts, you'll want to run UI and API separately in dev mode.\nSee the [frontend](frontend/README.md) and [backend](backend/README.md) READMEs for instructions.\n\n## Contributing\n\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)\n\nThank you for considering contributing to this open source project!\n\nPlease read the our [contributing guide](CONTRIBUTING.md) and our [code of conduct](CODE_OF_CONDUCT.md) first.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottlogic%2Fprompt-injection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscottlogic%2Fprompt-injection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottlogic%2Fprompt-injection/lists"}