Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule not working: Create/Modify Configmap With Private Credentials #1186

Closed
yinynick opened this issue May 5, 2020 · 4 comments · Fixed by #1323
Closed

Rule not working: Create/Modify Configmap With Private Credentials #1186

yinynick opened this issue May 5, 2020 · 4 comments · Fixed by #1323

Comments

@yinynick
Copy link

yinynick commented May 5, 2020

Rule - Create/Modify Configmap With Private Credentials seems not working by default following https://falco.org/docs/event-sources/kubernetes-audit/ on version 0.22.1.

Other k8s audit rules would flag without problems.

Command in use to create configmap:
kubectl create -f configmap.yaml

Audit log output:
{
"kind": "Event",
"apiVersion": "audit.k8s.io/v1",
"level": "RequestResponse",
"auditID": "59a27ad6-5164-46a9-8c63-0a71bcc2ed8e",
"stage": "ResponseComplete",
"requestURI": "/api/v1/namespaces/default/configmaps",
"verb": "create",
"user": {
"username": "kubernetes-admin",
"groups": [
"system:masters",
"system:authenticated"
]
},
"sourceIPs": [
"10.211.55.12"
],
"userAgent": "kubectl/v1.18.2 (linux/amd64) kubernetes/52c56ce",
"objectRef": {
"resource": "configmaps",
"namespace": "default",
"name": "my-config1",
"apiVersion": "v1"
},
"responseStatus": {
"metadata": {},
"code": 201
},
"requestObject": {
"kind": "ConfigMap",
"apiVersion": "v1",
"metadata": {
"name": "my-config1",
"namespace": "default",
"creationTimestamp": null
},
"data": {
"access.properties": "aws_access_key_id = MY-ID\naws_secret_access_key = MY-KEY\npassword = NICK\n"
}
},
"responseObject": {
"kind": "ConfigMap",
"apiVersion": "v1",
"metadata": {
"name": "my-config1",
"namespace": "default",
"selfLink": "/api/v1/namespaces/default/configmaps/my-config1",
"uid": "66cd8571-fa16-40fb-b485-293e6c2d4d61",
"resourceVersion": "219832",
"creationTimestamp": "2020-05-05T07:17:06Z",
"managedFields": [
{
"manager": "kubectl",
"operation": "Update",
"apiVersion": "v1",
"time": "2020-05-05T07:17:06Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:data": {
".": {},
"f:access.properties": {}
}
}
}
]
},
"data": {
"access.properties": "aws_access_key_id = MY-ID\naws_secret_access_key = MY-KEY\npassword = NICK\n"
}
},
"requestReceivedTimestamp": "2020-05-05T07:17:06.458299Z",
"stageTimestamp": "2020-05-05T07:17:06.461035Z",
"annotations": {
"authorization.k8s.io/decision": "allow",
"authorization.k8s.io/reason": ""
}
}

@yinynick yinynick added the kind/bug Something isn't working label May 5, 2020
@yinynick
Copy link
Author

yinynick commented May 5, 2020

Update: this rule is not working when the "user" is not in allowed_k8s_users, in my case "kubernetes-admin".

Are below known and correct behaviour?

  1. When user "kubernetes-admin" is not in list allowed_k8s_users:

kubectl delete configmap
kubectl create configmap config --from-file=configmap

Alerts flagged:
May 5 15:57:18 k8s-controlplane1 falco: 15:57:04.389830912: Warning K8s Operation performed by user not in allowed list of users (user=kubernetes-admin target=nickconfig/configmaps verb=create uri=/api/v1/namespaces/default/configmaps resp=201)
May 5 15:57:18 k8s-controlplane1 falco: 15:56:59.000089088: Warning K8s Operation performed by user not in allowed list of users (user=kubernetes-admin target=nickconfig/configmaps verb=delete uri=/api/v1/namespaces/default/configmaps/nickconfig resp=200)

  1. When user "kubernetes-admin" is in list allowed_k8s_users:

kubectl delete configmap
kubectl create configmap config --from-file=configmap

Alers flagged:
May 5 15:59:18 k8s-controlplane1 falco: 15:59:17.949396992: Notice K8s ConfigMap Deleted (user=kubernetes-admin configmap=nickconfig ns=default resp=200 decision=allow reason=)
May 5 15:59:48 k8s-controlplane1 falco: 15:59:22.695921920: Warning K8s configmap with private credential (user=kubernetes-admin verb=create configmap=nickconfig config={"test-config1":"apiVersion: v1\ndata:\n access.properties: |\n aws_access_key_id = MY-ID\n aws_secret_access_key = MY-KEY\n password = NICK\nkind: ConfigMap\nmetadata:\n name: my-config1\n namespace: default\n"})

@bzurkowski
Copy link

@yinynick I had the exact same issue with Create/Modify Configmap With Private Credentials rule. Solved it by adding kubernetes-admin to the list of allowed users.

@stale
Copy link

stale bot commented Jul 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 6, 2020
@stale stale bot closed this as completed Jul 13, 2020
@leogr
Copy link
Member

leogr commented Jul 13, 2020

Please, keep open.

I have had the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants