{"id":22963952,"url":"https://github.com/jnaulty/kubectl-apply-demo","last_synced_at":"2026-05-04T21:32:19.321Z","repository":{"id":64303929,"uuid":"231592951","full_name":"jnaulty/kubectl-apply-demo","owner":"jnaulty","description":"Security Implications of Running kubectl apply","archived":false,"fork":false,"pushed_at":"2020-01-09T22:43:57.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-26T11:49:53.236Z","etag":null,"topics":["kubernetes","security"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jnaulty.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-03T13:18:29.000Z","updated_at":"2021-07-28T22:53:16.000Z","dependencies_parsed_at":"2023-01-15T10:00:28.194Z","dependency_job_id":null,"html_url":"https://github.com/jnaulty/kubectl-apply-demo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jnaulty/kubectl-apply-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnaulty%2Fkubectl-apply-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnaulty%2Fkubectl-apply-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnaulty%2Fkubectl-apply-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnaulty%2Fkubectl-apply-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jnaulty","download_url":"https://codeload.github.com/jnaulty/kubectl-apply-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnaulty%2Fkubectl-apply-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32625982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"ssl_error","status_checked_at":"2026-05-04T10:08:02.005Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["kubernetes","security"],"created_at":"2024-12-14T19:42:44.491Z","updated_at":"2026-05-04T21:32:19.303Z","avatar_url":"https://github.com/jnaulty.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kubectl Apply Demo\n\nHere's a small demo app and static files to illustrate why you should not run `kubectl apply` commands for random `https` endpoints.\n\n## Demo\n\n1. Clone this repo: `git clone https://github.com/jnaulty/kubectl-apply-demo.git`\n2. `cd` into repo `cd kubectl-apply-demo`\n3. Build binary `go build` or download from release page `wget https://github.com/jnaulty/kubectl-apply-demo/releases/download/v0.1.0/kubectl-apply-demo`\n(`cf7dcfc0c9c37d3986361acdee1d4e5172350a85e39e6b9db9f76600cc7218d0` is the sha256sum of this binary)\n4. Run server in separate terminal or background `./kubectl-apply-demo`\n(You might need to make it executable if you downloaded it from github in Step 3, `chmod u+x kubectl-apply-demo`)\n5. Run `curl http://localhost:8080/harmless.yaml`\n6. Run `kubectl apply -f http://localhost:8080/harmless.yaml --dry-run -o yaml`\n7. Spot the difference\n\n## Kubectl Apply Info\n\n`kubectl apply` is used to `Apply a configuration change to a resource from a file or stdin.`\n\n### Problem\n\n`kubectl` documentation does not warn about the possible dangers of applying random yaml files from the internet.\n\nAn example from [k8s docs on \"Managing Resources\"](https://kubernetes.io/docs/concepts/cluster-administration/manage-deployment/) might have us believe that applying random yaml files from the internet is safe:\n`kubectl apply -f https://k8s.io/examples/application/nginx-app.yaml`\n\n\n### Solution\n\nApplying random things from the internet into a cluster seems like a good way for bad things to happen. Instead, I suggest the following pattern of \"get, inspect, apply\"\n\n**Get**: `curl https://k8s.io/examples/application/nginx-app.yaml -o nginx-app.yaml`\n\n**Inspect**: `cat nginx-app.yaml`\n\n**Apply**: `kubectl apply -f nginx-app.yaml`\n\nAt the very least, do something like `kubectl apply -f \u003cmy-possibly-dangerous-url\u003e --dry-run -o yaml` and inspect the output in the console.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjnaulty%2Fkubectl-apply-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjnaulty%2Fkubectl-apply-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjnaulty%2Fkubectl-apply-demo/lists"}