T09 · Insecure Skill Coding Practices
- Location
scripts/gitlab_api.sh:8- Finding
GitLab Access Token Can Be Transmitted over Plaintext HTTP
- Content
View full analysis
/dev/null || echo "https://gitlab.com")}" # Ensure URL has https:// prefix if [[ "$GITLAB_URL" != http* ]]; then GITLAB_URL="https://$GITLAB_URL" fi ``` The resulting URL is subsequently used to transmit the access token: ```bash curl -s -H "PRIVATE-TOKEN: $GITLAB_TOKEN" \ "$API_BASE/projects?owned=true&per_page=50" \ | jq -r '.[] | "\(.id)\t\(.path_with_namespace)\t\(.web_url)"' ``` The same token-bearing header is used by the read, write, delete, and directory-listing operations. ### Technical Analysis The URL validation condition accepts any value beginning with `http`, including an insecure `http://` URL. Consequently, the comment stating that the script ensures an HTTPS prefix does not reflect its actual behavior. The instance URL can be supplied through the `GITLAB_URL` environment variable or the user-controlled `~/.config/gitlab/instance_url` configuration file. If either source contains a plaintext HTTP endpoint, every API operation sends the GitLab personal access token in a `PRIVATE-TOKEN` request header without transport encryption. Because the documented token scopes include `api` or repository write access, disclosure of this header can expose a highly privileged credential. ### Attack Path 1. An attacker modifies `~/.config/gitlab/instance_url`, influences the `GITLAB_URL` environment variable, or causes the user to configure an endpoint beginning with `http://`. 2. The user invokes any command such as `list-projects`, `read-file`, `write-file`, `delete-file`, or `list-dir`. 3. The script accepts the HTTP URL because it begins with `http`. 4. `curl` s ...[truncated 949 chars]- Remediation
View remediation
&2 exit 1 ;; esac ``` ]]>
