Zum Hauptinhalt springen
LIVE Intel Feed

CircleCI Security

Pipeline Security 2026

OpenID Connect, Contexts, Restricted Contexts, IP Ranges & Secrets Management

OIDCContextsIP RangesSecrets

CircleCI Security Architecture

CircleCI Pipelines haben Zugriff auf Code, Secrets und Deployments. Mit OIDC, Restricted Contexts und IP-Ranges können Sie Sicherheit dramatisch verbessern.

OIDC Authentication

  • • AWS OIDC Provider
  • • Azure OIDC
  • • GCP Workload Identity
  • • Vault JWT Auth

Context Security

  • • Restricted Contexts
  • • Security Groups
  • • Approval Gates
  • • Rotation Policies

Network Security

  • • IP Ranges Product
  • • Self-Hosted Runners
  • • VPN Integration
  • • Firewall Rules

OIDC Configuration (AWS + CircleCI)

# Terraform - AWS OIDC Provider for CircleCI

# 1. Create OIDC Provider
resource "aws_iam_openid_connect_provider" "circleci" {
  url = "https://oidc.circleci.com/org/YOUR_ORG_ID"

  client_id_list = ["YOUR_ORG_ID"]

  thumbprint_list = [
    "9e99a48a9960b14926bb7f3b02e22da2b0ab7280"  # CircleCI OIDC thumbprint
  ]
}

# 2. IAM Role with Trust Policy
resource "aws_iam_role" "circleci_deploy" {
  name = "CircleCIDeployRole"

  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Effect = "Allow"
        Principal = {
          Federated = aws_iam_openid_connect_provider.circleci.arn
        }
        Action = "sts:AssumeRoleWithWebIdentity"
        Condition = {
          StringEquals = {
            "oidc.circleci.com/org/YOUR_ORG_ID:aud" = "YOUR_ORG_ID"
          }
          StringLike = {
            # Only allow specific projects/branches
            "oidc.circleci.com/org/YOUR_ORG_ID:sub" = [
              "org/YOUR_ORG_ID/project/*/user/*/pipeline/*",
              "org/YOUR_ORG_ID/project/my-production-repo/*"
            ]
          }
        }
      }
    ]
  })
}

# 3. Least Privilege Policy
resource "aws_iam_role_policy" "deploy_policy" {
  name = "CircleCIDeployPolicy"
  role = aws_iam_role.circleci_deploy.id

  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Sid = "ECSDeploy"
        Effect = "Allow"
        Action = [
          "ecs:RegisterTaskDefinition",
          "ecs:UpdateService",
          "ecs:DescribeServices",
          "iam:PassRole"
        ]
        Resource = "*"
        Condition = {
          StringEquals = {
            "ecs:cluster" = "arn:aws:ecs:*:*:cluster/production"
          }
        }
      },
      {
        Sid = "ECRPush"
        Effect = "Allow"
        Action = [
          "ecr:GetAuthorizationToken",
          "ecr:BatchCheckLayerAvailability",
          "ecr:GetDownloadUrlForLayer",
          "ecr:BatchGetImage",
          "ecr:InitiateLayerUpload",
          "ecr:UploadLayerPart",
          "ecr:CompleteLayerUpload",
          "ecr:PutImage"
        ]
        Resource = "arn:aws:ecr:*:*:repository/production/*"
      }
    ]
  })
}

# CircleCI Config - Use OIDC
# .circleci/config.yml
version: 2.1

orbs:
  aws-cli: circleci/aws-cli@4.1

jobs:
  deploy:
    docker:
      - image: cimg/python:3.11
    steps:
      - checkout
      
      # Install AWS CLI v2 with OIDC support
      - aws-cli/setup:
          profile_name: default
          role_arn: "arn:aws:iam::123456789:role/CircleCIDeployRole"
          session_duration: '900'  # 15 minutes
      
      # Now authenticated with temporary credentials
      - run:
          name: Deploy to ECS
          command: |
            aws ecs update-service \
              --cluster production \
              --service my-app \
              --force-new-deployment

workflows:
  deploy:
    jobs:
      - deploy:
          filters:
            branches:
              only: main
          context: production-aws

Restricted Contexts & Security Groups

# CircleCI Contexts Configuration

# Via CircleCI API / Web UI

# 1. Create Restricted Context
POST https://circleci.com/api/v2/context
{
  "name": "production-secrets",
  "owner": {
    "id": "YOUR_ORG_ID",
    "type": "organization"
  }
}

# 2. Add Environment Variables
POST https://circleci.com/api/v2/context/{context-id}/environment-variable
{
  "variable": {
    "name": "AWS_ACCESS_KEY_ID",
    "value": "AKIA..."  # Encrypted at rest
  }
}

POST https://circleci.com/api/v2/context/{context-id}/environment-variable
{
  "variable": {
    "name": "DATABASE_URL",
    "value": "postgresql://..."
  }
}

# 3. Configure Restrictions (CircleCI Web UI)
# Go to Organization Settings > Security > Restricted Contexts

# Example: Restrict "production-secrets" context
restrictions:
  # Only allow specific GitHub teams
  teams:
    - platform-engineering
    - sre-team
  
  # Require approval for first-time contributors
  approval:
    require_approval: true
    approval_timeout: 24h
  
  # IP Restrictions (requires IP Ranges product)
  ip_ranges:
    allowed:
      - "203.0.113.0/24"  # Office VPN
      - "198.51.100.0/24" # Data Center
  
  # Schedule-based restrictions
  schedule:
    deploy_window:
      days: [monday, tuesday, wednesday, thursday]
      hours: [9, 10, 11, 14, 15, 16]

# CircleCI Config with Multiple Contexts
version: 2.1

jobs:
  test:
    docker:
      - image: cimg/node:20.0
    steps:
      - checkout
      - run: npm ci
      - run: npm test

  build:
    docker:
      - image: cimg/node:20.0
    steps:
      - checkout
      - run: npm ci
      - run: npm run build

  deploy-staging:
    docker:
      - image: cimg/python:3.11
    steps:
      - checkout
      - run: ./deploy.sh staging

  deploy-production:
    docker:
      - image: cimg/python:3.11
    steps:
      - checkout
      - run: ./deploy.sh production

workflows:
  ci-cd:
    jobs:
      - test
      
      - build:
          requires: [test]
      
      - deploy-staging:
          requires: [build]
          context: staging-secrets
          filters:
            branches:
              ignore: main
      
      - hold-for-production:
          type: approval
          requires: [build]
          filters:
            branches:
              only: main
      
      - deploy-production:
          requires: [hold-for-production]
          context: production-secrets  # Restricted context!
          filters:
            branches:
              only: main
          # Additional security: require manual approval
          # configured in CircleCI web UI for restricted contexts

IP Ranges & Self-Hosted Runners

# CircleCI IP Ranges (Paid Feature)
# Enable in Project Settings > Advanced > IP Ranges

# List of CircleCI IP ranges (keep updated!)
# https://circleci.com/docs/ip-ranges

circleci_ip_ranges:
  aws:
    - 3.228.14.0/24
    - 3.228.15.0/24
    - 18.214.240.128/25
    - 52.20.179.168/32
    - 52.203.65.204/32
  
  gcp:
    - 34.75.0.0/16
    - 35.185.0.0/16
  
  azure:
    - 40.76.0.0/16
    - 40.77.0.0/16

# AWS Security Group for CircleCI
resource "aws_security_group" "circleci" {
  name_prefix = "circleci-ip-ranges-"
  description = "Allow CircleCI IP ranges"
  vpc_id      = aws_vpc.main.id

  ingress {
    description = "HTTPS from CircleCI"
    from_port   = 443
    to_port     = 443
    protocol    = "tcp"
    cidr_blocks = [
      "3.228.14.0/24",
      "3.228.15.0/24",
      "18.214.240.128/25",
    ]
  }

  # Enable IP Ranges in CircleCI
  # .circleci/config.yml
  version: 2.1

  jobs:
    deploy:
      circleci_ip_ranges: true  # Enable IP ranges for this job
      docker:
        - image: cimg/python:3.11
      steps:
        - checkout
        - run:
            name: Deploy
            command: ./deploy.sh

  workflows:
    deploy:
      jobs:
        - deploy:
            context: production
}

# Self-Hosted Runner for Maximum Security
# Install CircleCI Runner on your infrastructure

# runner-config.yaml
api:
  auth_token: "YOUR_RUNNER_TOKEN"

runner:
  name: "prod-runner-01"
  working_directory: "/var/lib/circleci/workdir"
  cleanup_working_directory: true
  
  # Resource limits
  max_run_time: 1h
  max_concurrent_tasks: 4

logging:
  level: info
  format: json
  file: "/var/log/circleci-runner.log"

# Docker Runner Configuration (Docker-in-Docker)
resource_class: company/self-hosted

docker:
  image: "cimg/base:stable"
  auth:
    username: $DOCKER_USER
    password: $DOCKER_PASS

# Kubernetes Runner (Container Agent)
apiVersion: apps/v1
kind: Deployment
metadata:
  name: circleci-container-agent
  namespace: circleci
spec:
  replicas: 3
  selector:
    matchLabels:
      app: circleci-agent
  template:
    metadata:
      labels:
        app: circleci-agent
    spec:
      containers:
      - name: agent
        image: circleci/container-agent:1.0
        resources:
          limits:
            cpu: "2"
            memory: 4Gi
          requests:
            cpu: "1"
            memory: 2Gi
        env:
        - name: RUNNER_TOKEN
          valueFrom:
            secretKeyRef:
              name: circleci-runner-token
              key: token
        securityContext:
          runAsNonRoot: true
          readOnlyRootFilesystem: true
          allowPrivilegeEscalation: false
          capabilities:
            drop:
            - ALL

CircleCI Security Checklist

Authentication & Access

☐OIDC configured (AWS/Azure/GCP)
☐Restricted contexts enabled
☐Team-based access controls
☐2FA for all org members

Pipeline Security

☐No hardcoded secrets in config.yml
☐IP ranges enabled for sensitive jobs
☐Approval gates for production
☐Orb pinning (version locks)

CircleCI Security Assessment

Assessment Starten
🔒 Quantum-Resistant Mycelium Architecture
🛡️ Kuratierte Runbooks – EU-gehostet in Frankfurt
🌐 Zero Known Breaches – Powered by Living Intelligence
🏛️ DSGVO Art. 25 & 32 • SOC 2 & ISO 27001 in Vorbereitung
⚡ Real-Time Global Mycelium Network – 347 Bedrohungen in 60 Minuten
🧬 Trusted by SecOps Leaders worldwide