Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.
generated from Kong/kong-plugin

kong-hello-world-plugin allows kong to execute an arbitrary command with parameters on the host.

License

Notifications You must be signed in to change notification settings

gpetrousov/kong-hello-world-plugin

Repository files navigation

kong-run-command-plugin

This is a barebones Kong plugin I put together in a few hours to showcase how someone can use Kong as an execution server. The server accepts an arbitrary command with arguments - either throught the URL or request headers - and executes it as a script.

Checkout my blogpost on Medium

Note

A note of warning is required here. The plugin will run absolutely any command it's allowed to making Kong command injection vulnerable. Use at your own risk.

Usage and installation

  1. Start the kong container
docker run -it --rm --name kong-dbless-dev \
  --network=kong-gw \
  -v "$(pwd):/kong/declarative/" \
  -e "KONG_DATABASE=off" \
  -e "KONG_DECLARATIVE_CONFIG=/kong/declarative/kong.yml" \
  -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
  -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
  -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
  -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
  -e "KONG_ADMIN_LISTEN=0.0.0.0:8001" \
  -p 8000:8000 \
  -p 8443:8443 \
  -p 8001:8001 \
  -p 8444:8444 \
  -p 8002:8002 \
  -p 8445:8445 \
  -p 8003:8003 \
  -p 8004:8004 \
  --user 0:0 \
kong/kong-gateway:3.2.2.1 bash
  1. Validate config
kong config -c kong.conf parse kong.yml
  1. Install plugin
luarocks make
  1. Check the plugin is installed
/usr/local/lib/luarocks/rocks-5.1/kong-hello-world-plugin
  1. Start kong
export KONG_DATABASE=off
kong start -c kong.conf
  1. Test the plugin is working

You should see the output in the container logs.

curl -X GET -IL http://localhost:8000/hello_world_path\?cmd\=ls\&arg\=-l

About

kong-hello-world-plugin allows kong to execute an arbitrary command with parameters on the host.

Topics

Resources

License

Stars

Watchers

Forks

Languages