Lemma
Remote CLI tools at your fingertips
Install / Use
/learn @sleepyeinstein/LemmaREADME
Disclaimer
The author of this project is not responsible for any damage or data loss incurred as a result of using this software. Use this software at your own risk. While efforts have been made to ensure the accuracy and reliability of the software, it is provided "as is" without warranty of any kind. By using this software, you agree to assume all risks associated with its use. Opinions are that of the author and not that of AWS. Review the AWS pentesting policy prior to executing any security tools on AWS Lambda.
Lemma
Lemma is a Python-based AWS Lambda package and client designed to execute packaged command-line tools in a scalable, remote environment on AWS Lambda. Lemma takes advantage of the new Response Streaming feature on AWS Lambda to stream real-time stdout back to the user as the tool is running. The Lemma project comprises three main components:
-
Lemma Lambda Function Package: This package bundles a collection of command-line Linux tools provided by the user, making them accessible via AWS Lambda. It allows users to execute these tools remotely and scale their executions across multiple lambda instances.
-
Web-CLI: This component provides a web-based terminal interface built with xterm.js, AWS Lambda Web Adapter and FastAPI, accessible via the Lambda URL. This web UI allows users to execute their command-line tools packaged in the Lambda entirely within their web browser.
-
Terminal-CLI: A python-based command-line interface tool in charge invoking the Lemma Lambda function. This tool facilitates the remote execution of the Lambda-hosted tools from a local environment. It pipes stdin and stdout between local and remote tools, providing the ability to execute and scale cli-based workflows onto lambda and back using pipes.
While the intented use case for Lemma is to run verbose security security tooling on AWS lambda, Lemma can be used for any type of command-line tool you wish to run remotely.
Demo
Web-CLI:
<h1 align="center"> <img src="images/demo.gif"> <br> </h1> Terminal-CLI: <h1 align="center"> <img src="images/demo2.gif"> <br> </h1>Features
- Supports both a Web-CLI and a Terminal-CLI
- Quick and easy build script
- Support for adding your own custom tools
- Support for x86_64 and ARM64 lambda types
- Support for choosing memory, region and timeout
- Flexible terminal piping support
Installation
Requirements for Lemma Lambda
- An AWS account
- AWS access credentials with permissions to execute cloudformation templates
- Docker, python3 with pip
Lambda Build and Deploy Steps
Steps to build and deploy on a fresh Ubuntu 22 instance
sudo apt updatesudo apt install docker.io python3 python3-pipgit clone https://github.com/defparam/lemmacd lemmaexport AWS_ACCESS_KEY_ID=<your access key id>export AWS_SECRET_ACCESS_KEY=<your secret access key>./build.sh- Fill out all the questions
- Copy the lambda URL with the key
Web-CLI:
- Open chrome and simply browse to your lambda URL w/key
Terminal-CLI:
- While in the lemma directory:
pip3 install .(The Terminal-CLI is also available on pypi:pip install lemmacli) - Invoke:
lemma - When asked about the lambda URL, paste it into the prompt. This URL will be saved at
~/.lemma/lemma.ini
Build Walkthrough:
<h1 align="center"> <img src="images/build.gif"> <br> </h1>Lemma Web Client
Lemma's web client is packaged inside the Lemma function itself for easy access. It simply is just 1 html file and 1 javascript file (Also importing xterm.js from CDN). To access it simply just copy and paste your lemma lambda url/key into your chrome web browser and hit enter. For usage details just type the help command.
Lemma Terminal Client
Usage
positional arguments:
remote_command lemma <options> -- remote_command
options:
-h, --help show this help message and exit
-w WORKERS, --workers WORKERS
Number of concurrent Lambda service workers
-l, --lambda-url Prompt user to enter a new lambda url
-i INVOCATIONS, --invocations INVOCATIONS
The number of invocations of the remote command
-p, --per-stdin Invoke the remote command for each line of stdin (-i is ignored)
-d DIV_STDIN, --div-stdin DIV_STDIN
Divide stdin into DIV_STDIN parts at a newline boundary and invoke on each (-i is ignored)
-o, --omit-stdin Omit stdin to the remote command stdin
-e, --no-stderr prevent stderr from being streamed into response
-b, --line-buffered Stream only line chunks to stdout
-v, --verbose Enable verbose remote output
-t, --tools List available tools
| Remote Command Macro | Description
|-------------------------|----------------------------------------------------
| %INDEX% | You can place this macro on a remote command to insert the current invocation count into the command (starts at 0)
| %STDIN% | You can place this macro on a remote command to insert any data that may exist on lemma client's stdin. (Warning: new line characters aren't permitted except in -p mode)
FAQ
Q: Why did you make this? Aren't there other frameworks?
A: I recently read about a new lambda feature Response Streaming that was only a year old and thought about how wonderful it would be in linux to pipe lambda streams together with security tooling because prior to that all responses back from lambda were buffered. Futhermore, I saw lambda's web adapter and though it would be a super neat feature to have lambda present a web page of a terminal to invoke these streaming commands.
Q: Does this work on MacOS or Windows?
A: In theory yes, but at this point i've only tested linux.
Q: Do you support other cloud providers?
A: No, mainly because I'm not sure if other cloud providers even support response streaming with their FaaS product and secondly I don't have the time to research it and make this tool generic.
Q: How do I package my own tools?
A: If you have a normal bash script, simply move it into the ./tools directory, make it executable and re-build your lambda, its that easy. If your tool installation requires more advanced setup then place those steps into ./tools/install_tools.sh and re-build your lambda. NOTE: inside a lambda the only writable directory is /tmp, so if your tool needs a mutable settings area create a wrapper script to manage it at /tmp
Q: Why do you support both arm64 and x86_64?
A: If you end up running A LOT of executions to the point where you care about your AWS bill you may want to use arm64 architecture since it is generally billed cheaper than x86_64. Also billing rates are slightly different depending on the region and memory requirements as well.
Q: Where do I get my AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY ?
A: You can generate it when you log into your AWS account in IAM. I won't go into how to do this since there are plenty of resources you can google.
Q: How come I can only run 10 parallel lambdas at a time?
A: This is a quota set for all new AWS accounts. To increase it to 100-1000 you have to place a quota increase request into AWS through your account.
Q: What's the deal with the key parameter on the Lambda URLs?
A: So this lambda application basically provides an RCE API. These lambda URLs are publically accessible. There is a IAM AUTH mode where you can sign your requests with SigV4 but I haven't implemented it yet. As a band-aid solution I added a poor-man's randomly generated API key. When you access it with the key it sets it as a cookie and redirects you back to the root page. If the key is not correct the lambda will return 404. In general I recommend only keeping your lambda url public at times of use then disable/delete it.
Q: Does lambda support streaming data into stdin of a function?
A: No, not at this time. When the client invokes a function all stdin is known and transmitted on invoke. Only stdout of a lambda function supports streaming.
Q: I have a tool/workload that requires more than 15 minutes, how can i increase the lambda timeout?
A: You can't. Lambda is strict on the timeout being max 15 minutes. The way to solve this problem is to break your workflow down to partial executions that execute under 15 minutes.
Q: On the lemma python client what's the deal with these -i, -p and -d modes?
A: These modes are all mutually exclusive and if none of them are specified it is assumed the mode is -i 1. The -i mode flag allows you to explicitly specify the number of lambda executions of the remote command. The -p mode flag tells the client that for all stdin data presented to the client, perform a lambda execution for each "line" of stdin and place th
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
Security Score
Audited on Mar 2, 2026
