This rule ensures that CodeBuild projects use OAuth for GitHub or Bitbucket source repository URLs.
Rule | CodeBuild GitHub or Bitbucket source repository URLs should use OAuth |
Framework | SOC 2 |
Severity | ✔ Critical |
CodeBuild GitHub or Bitbucket Source Repository URLs Should Use OAuth
Overview
For AWS CodeBuild projects that use GitHub or Bitbucket as a source repository, it's essential to use OAuth tokens for secure authentication. This is particularly important when aiming to comply with SOC 2 standards. Using OAuth tokens in place of traditional user credentials helps in providing a more secure and controlled way of accessing repositories, ensuring that access is only granted to necessary personnel or services and is auditable for security compliance.
Troubleshooting Steps
If AWS CodeBuild is not using OAuth tokens for GitHub or Bitbucket repositories, you should take the following actions:
Verify OAuth Token Usage
Build projects
and select the project you want to verify.Source
section.Repository
, check to see if you are using a repository URL that starts with https://
and if you've connected using an OAuth token.Check IAM Policies
Make sure that the IAM role used by your CodeBuild project has the necessary policies attached to interact with OAuth tokens.
Inspect CodeBuild Logs
Build history
tab and click on the specific build run.Remediation Steps
To remediate this, set up OAuth integration for GitHub or Bitbucket within AWS CodeBuild:
GitHub OAuth Integration
Edit
and navigate to the Source
section.GitHub
or GitHub Enterprise Cloud
as the source provider.Connect to GitHub
to authorize AWS CodeBuild to access your GitHub repositories using OAuth.Bitbucket OAuth Integration
Edit
, then go to the Source
section.Bitbucket
.Connect to Bitbucket
.Necessary CLI Commands
To perform these steps using the AWS CLI:
Update CodeBuild Project for GitHub Source
aws codebuild update-project \ --name "project-name" \ --source type=GITHUB,location=oauth-token@github.com/owner/repo-name.git,authType=OAUTH
Replace
project-name
, oauth-token
, owner
, and repo-name
with the appropriate values.Update CodeBuild Project for Bitbucket Source
aws codebuild update-project \ --name "project-name" \ --source type=BITBUCKET,location=oauth-token@bitbucket.org/owner/repo-name.git,authType=OAUTH
Replace
project-name
, oauth-token
, owner
, and repo-name
with the appropriate values.After updating your build projects to use OAuth, monitor your builds to ensure they can successfully access your repositories.
Remember to secure your OAuth tokens and rotate them regularly according to your organization's security policy. This is key to maintaining ongoing SOC 2 compliance and ensuring the continued security of your builds and code repositories.