{"record":{"id":"3c49e9156e255018","repo":"juanfont/headscale","slug":"autogroup-not-supported-for-ssh-sources","errorCode":null,"errorMessage":"autogroup not supported for SSH sources","messagePattern":"autogroup not supported for SSH sources","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hscontrol/policy/v2/types.go","lineNumber":140,"sourceCode":"\tErrInvalidOwner                = errors.New(\"invalid owner format\")\n\tErrGroupNotDefined             = errors.New(\"group not defined in policy\")\n\tErrInvalidGroupMember          = errors.New(\"invalid group member type\")\n\tErrGroupValueNotArray          = errors.New(\"group value must be an array of users\")\n\tErrInvalidHostIP               = errors.New(\"hostname contains invalid IP address\")\n\tErrTagNotDefined               = errors.New(\"tag not found\")\n\tErrAutoApproverNotAlias        = errors.New(\"auto approver is not an alias\")\n\tErrInvalidACLAction            = errors.New(\"invalid ACL action\")\n\tErrInvalidSSHAction            = errors.New(\"invalid SSH action\")\n\tErrInvalidProtocolNumber       = errors.New(\"invalid protocol number\")\n\tErrProtocolLeadingZero         = errors.New(\"leading 0 not permitted in protocol number\")\n\tErrProtocolOutOfRange          = errors.New(\"protocol number out of range (0-255)\")\n\tErrAutogroupNotSupported       = errors.New(\"autogroup not supported in headscale\")\n\tErrAutogroupInternetSrc        = errors.New(\"autogroup:internet can only be used in ACL destinations\")\n\tErrAutogroupSelfSrc            = errors.New(\"\\\"autogroup:self\\\" not valid on the src side of a rule\")\n\tErrAutogroupNotSupportedACLSrc = errors.New(\"autogroup not supported for ACL sources\")\n\tErrAutogroupNotSupportedACLDst = errors.New(\"autogroup not supported for ACL destinations\")\n\tErrAutogroupDangerAllDst       = errors.New(\"cannot use autogroup:danger-all as a dst\")\n\tErrAutogroupNotSupportedSSHSrc = errors.New(\"autogroup not supported for SSH sources\")\n\tErrAutogroupNotSupportedSSHDst = errors.New(\"autogroup not supported for SSH destinations\")\n\tErrHostNotDefined              = errors.New(\"host not defined in policy\")\n\tErrSSHSourceAliasNotSupported  = errors.New(\"alias not supported for SSH source\")\n\tErrSSHDestAliasNotSupported    = errors.New(\"alias not supported for SSH destination\")\n\tErrUnknownField                = errors.New(\"unknown field\")\n\tErrProtocolNoSpecificPorts     = errors.New(\"protocol does not support specific ports\")\n\tErrTestEmptyAssertions         = errors.New(\"test entry must have at least one of \\\"accept\\\" or \\\"deny\\\"\")\n\tErrTestProtocolNotAllowed      = errors.New(\"test protocol must be tcp, udp, sctp, or empty\")\n\tErrTestDestinationMultiPort    = errors.New(\"test destination port must be a single port\")\n\tErrTestDestinationCIDR         = errors.New(\"test destination must be a single host, not a CIDR range\")\n\tErrAutogroupInternetTestDst    = errors.New(\"autogroup:internet not valid as a test destination\")\n\tErrSSHTestEmptySrc             = errors.New(\"SSH tests entry must have a non-empty src\")\n\tErrSSHTestEmptyDst             = errors.New(\"SSH tests entry must have at least one dst\")\n\tErrSSHTestDstUnknownTag        = errors.New(\"SSH tests dst contains unknown tag\")\n\tErrSSHTestDstDisallowedElement = errors.New(\"SSH tests dst contains disallowed element\")\n)\n\ntype resolved struct {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/policy/v2/types.go#L122-L158","documentation":"Returned by validateAutogroupForSSHSrc (hscontrol/policy/v2/types.go:2119) when an autogroup in an SSH rule's src is not in autogroupForSSHSrc = {autogroup:member, autogroup:tagged} (types.go:2000). autogroup:internet in SSH src gets the dedicated ErrAutogroupInternetSrc (2115) first. SSH sources describe who may initiate SSH, so only device-class autogroups are legal.","triggerScenarios":"An SSH rule like {\"src\": [\"autogroup:self\"], ...} — self is not a legal SSH source and hits this (it is not special-cased on the SSH path, unlike the ACL path). Any non-member/tagged autogroup other than internet lands here.","commonSituations":"Porting ACL habits into sshTests/ssh sections; assuming autogroup:self works in SSH src because it exists in the ACL vocabulary.","solutions":["Use autogroup:member (user-owned devices) or autogroup:tagged (tagged devices) as SSH src","Replace autogroup:self src with the specific user or group that should connect","Validate ssh and sshTests sections together — both go through the same validator"],"exampleFix":"// before\n\"ssh\": [{\"action\": \"accept\", \"src\": [\"autogroup:self\"], \"dst\": [\"tag:server\"], \"users\": [\"root\"]}]\n\n// after\n\"ssh\": [{\"action\": \"accept\", \"src\": [\"autogroup:member\"], \"dst\": [\"tag:server\"], \"users\": [\"root\"]}]","handlingStrategy":"validation","validationCode":"sshSrcAutogroups := map[string]bool{\"autogroup:member\": true, \"autogroup:tagged\": true}\nfor _, r := range sshRules {\n\tfor _, s := range r.Src {\n\t\tif strings.HasPrefix(s, \"autogroup:\") && !sshSrcAutogroups[s] {\n\t\t\treturn fmt.Errorf(\"%s not allowed as SSH src\", s)\n\t\t}\n\t}\n}","typeGuard":"func isAutogroupNotSupportedSSHSrc(err error) bool {\n\treturn errors.Is(err, policy.ErrAutogroupNotSupportedSSHSrc)\n}","tryCatchPattern":"if err := p.Validate(); err != nil {\n\tif errors.Is(err, policy.ErrAutogroupNotSupportedSSHSrc) {\n\t\treturn fmt.Errorf(\"SSH src autogroup must be member or tagged: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["SSH sources allow only users, groups, tags, autogroup:member, autogroup:tagged","Do not carry ACL autogroup vocabulary into ssh sections","Validate sshTests with the same rules as ssh — they share validators"],"tags":["policy","autogroup","ssh","validation"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}