← 输入框|github.com|刷新
Skip to content

Parser service account cannot get resource parsedefinitions #2003

Description

@moxli

🐞 Bug report

Describe the bug

I am seeing the following error in my parser pod logs:

Nikto:

parsedefinitions.execution.securecodebox.io "nikto-json" is forbidden: User "system:serviceaccount:securecodebox:parser" cannot get resource "parsedefinitions" in API group "execution.securecodebox.io" in the namespace "securecodebox"

ZAP:

parsedefinitions.execution.securecodebox.io "zap-xml" is forbidden: User "system:serviceaccount:securecodebox:parser" cannot get resource "parsedefinitions" in API group "execution.securecodebox.io" in the namespace "securecodebox"

The pod will stop with exit code 1:

    State:          Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Sun, 01 Oct 2023 20:32:22 +0200
      Finished:     Sun, 01 Oct 2023 20:32:24 +0200
    Ready:          False
    Restart Count:  0

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install (or upgrade?) version 4.1.0
  2. Create a Nikto or ZAP scan
  3. See the error in the parser pod after the scan has finished

Expected behavior

I expect SecureCodeBox to set the correct rolebindings for me, so the parser can run without errors.

Should the parser service account have the clusterrole parsedefinition-viewer-role assigned?

System (please complete the following information):

  • secureCodeBox Version/Release: 4.1.0
  • OS: Linux
  • Kubernetes Version: v1.24.14-gke.2700
  • Docker: N/A

Screenshots / Logs

Parser Pod Logs:

  body: {
    kind: 'Status',
    apiVersion: 'v1',
    metadata: {},
    status: 'Failure',
    message: 'parsedefinitions.execution.securecodebox.io "nikto-json" is forbidden: User "system:serviceaccount:securecodebox:parser" cannot get resource "parsedefinitions" in API group "execution.securecodebox.io" in the namespace "securecodebox"',
    reason: 'Forbidden',
    details: {
      name: 'nikto-json',
      group: 'execution.securecodebox.io',
      kind: 'parsedefinitions'
    },
    code: 403
  },
  statusCode: 403

Additional context

The issue started occuring after I have upgraded to SecureCodeBox 4.1.0!

I also upgraded the following CRDs to make the 4.1.0 release work:

 k apply -f https://github.com/secureCodeBox/secureCodeBox/raw/v4.1.0/operator/crds/execution.securecodebox.io_clusterparsedefinitions.yaml
 k apply -f https://github.com/secureCodeBox/secureCodeBox/raw/v4.1.0/operator/crds/execution.securecodebox.io_parsedefinitions.yaml
 k apply -f https://github.com/secureCodeBox/secureCodeBox/raw/v4.1.0/operator/crds/execution.securecodebox.io_scheduledscans.yaml

Rolebindings (k get rolebindings.rbac.authorization.k8s.io):

NAME                          ROLE                        AGE
leader-election-rolebinding   Role/leader-election-role   6d17h
lurker                        Role/lurker                 20d
parser                        Role/parser                 20d
scan-completion-hook          Role/scan-completion-hook   20d

Clusterroles (k get clusterroles.rbac.authorization.k8s.io | grep parse)

parsedefinition-editor-role                                            2023-09-27T15:34:44Z
parsedefinition-viewer-role                                            2023-09-27T15:34:44Z

Activity

  1. moved this from Backlog to Todo in secureCodeBoxon Oct 4, 2023
  2. Weltraumschaf commented on Oct 4, 2023

    @Weltraumschaf
    Member

    @moxli Thanks for submitting this issue. We'll investigate it.

  3. J12934 commented on Oct 20, 2023

    @J12934
    Member

    @Ilyesbdlala can you have a look at this when you find time?
    i think there is a issue with the workaround with the amass fix which increase the permissions for the parser service account.

    As a workaround:
    The Operator will automatically recreate the ServiceAccount, Role & RoleBinding when its missing.

    So as a workaround delete the resources, the operator should recreate them correctly on the next scan execution:

    kubectl delete serviceaccount parser
    kubectl delete role parser
    kubectl delete rolebinding parser
  4. o1oo11oo commented on Oct 20, 2023

    @o1oo11oo
    Contributor

    I've hit the same problem with my local trivy and trivy-sbom scans, uninstalling the old and installing the current version of the operator and then recreating the integration-tests namespace (where my scans are running) fixed the issue for me (for now?)

  5. moved this from Todo to In Progress in secureCodeBoxon Oct 25, 2023
  6. added 2 commits that reference this issue on Oct 31, 2023
  7. added a commit that references this issue on Nov 7, 2023
  8. moved this from In Progress to Done in secureCodeBoxon Nov 7, 2023
  9. reopened this on Feb 23, 2024
  10. J12934 commented on Feb 23, 2024

    @J12934
    Member

    Permission to update the role went missing again in the newest release, think it was accidentally dropped when somebody was rebasing / updating their branch :(
    Will open up a pr to fix this again

  11. moved this from Backlog to In Progress in secureCodeBoxon Feb 23, 2024
  12. added 5 commits that reference this issue on Feb 23, 2024
  13. added a commit that references this issue on Feb 23, 2024
  14. moved this from In Progress to Done in secureCodeBoxon Feb 23, 2024
  15. added 2 commits that reference this issue on Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions