Back to exam

GH-500 Cheatsheet

GitHub Advanced Security

Download free PDF

Security features and ecosystem 15 to 20%

Match the control to the risk

  • **Code scanning** finds vulnerabilities and coding errors in source code. **Secret scanning** detects exposed credentials. **Dependabot alerts** identify known vulnerabilities in dependencies.
  • **Dependency review** shows dependency changes in a pull request, including vulnerable versions and licenses. **Push protection** checks supported secrets before accepting a push.
  • **Security updates** propose dependency fixes; **version updates** keep dependencies current even without a known vulnerability. Detection, remediation and merge enforcement are separate controls.
  • **GitHub Code Security** and **GitHub Secret Protection** package different capabilities. Public repositories receive many security features without a paid add-on; private and internal availability depends on the plan and enabled products.

Find findings and reporting guidance

  • The repository **Security tab** groups code scanning, secret scanning and Dependabot findings. Repository **Settings** controls enablement, permissions and check thresholds.
  • **Security overview** aggregates coverage, risk and remediation across repositories. Its results reflect the viewer's access and the features enabled in those repositories.
  • **SECURITY.md** describes supported versions and how to report a vulnerability safely. It guides disclosure; it does not scan code or enforce workflow checks.
  • **Repository security advisories** support private discussion, coordinated fixes and eventual publication. Follow the reporting policy instead of publishing exploit details in a public issue.

Secret Protection 15 to 20%

Detection scope and validity

  • **Secret scanning** examines repository content, including Git history across branches. Deleting a line from the current file leaves earlier commits available. The scan is read-only and does not modify source code.
  • **Provider patterns** recognize supported credentials, such as tokens and private keys. **Custom patterns** cover organization-specific formats. Generic or non-provider detection has different coverage and confidence.
  • Public repository **partner scanning** can notify the issuing service provider. Provider notification and repository alert access are different mechanisms; a security alert is not a public disclosure.
  • **Validity checks** verify whether supported provider secrets remain active. Prioritize **active** credentials; **unknown** means validity could not be established, not that the secret is safe.
  • Repeated occurrences of the **same secret** in one repository normally share an alert with multiple locations. Inspect every location and the relevant commit history.
  • **Paired credentials**, such as supported AWS key IDs and secret keys, require both elements in the same file for pair detection. Splitting them across files can evade this matching rule.

Prevent exposure and govern bypasses

  • **Push protection** blocks supported secrets before they enter the repository. It is credential prevention, while code scanning identifies code defects through analysis.
  • A blocked contributor should remove the credential from every affected commit before retrying. Moving it to a different file or creating a later deletion commit does not reliably remove the exposure.
  • Without stricter policy, contributors with **write access** can bypass repository push protection with a reason. A bypass records an exception and can create an alert; it does not revoke the credential.
  • **Delegated bypass** routes requests to authorized reviewers. Configure the designated team as reviewers so membership determines who may approve or deny requests.
  • **Bypass privileges** control who may bypass protection; **delegated review** controls approval of other users' requests. Audit bypass reasons and avoid treating temporary protection disablement as an exception process.

Custom patterns and exclusions

  • Enable **secret scanning** before defining custom patterns. Supply a **pattern name** and **secret format** regular expression; optional surrounding context and additional match requirements reduce false positives.
  • Run a **dry run**, inspect matches and refine the expression before publishing. Published patterns can scan existing content as well as detect future leaks.
  • **Custom-pattern push protection** is enabled deliberately for the pattern after validation. Publishing a custom detector alone does not establish a safe blocking policy.
  • Use **.github/secret_scanning.yml** with **paths-ignore** for narrowly justified exclusions. This configuration is separate from CodeQL configuration and workflow event filters.
  • Only the first **1,000 paths-ignore entries** are honored. A configuration file **larger than 1 MB** is ignored. Keep exclusions small and review them so real credentials are not hidden.

Supply chain security 15 to 20%

Inventory and vulnerability detection

  • The **dependency graph** parses supported manifests and lock files to inventory direct and transitive dependencies. Dependency submission can supply build-resolved dependencies missing from static manifests.
  • **Direct dependencies** are declared by the project. **Transitive dependencies** arrive through other packages; lock files can reveal their resolved versions and paths.
  • **Dependabot alerts** compare supported dependency information with the **GitHub Advisory Database**. A new vulnerable dependency or a new advisory affecting an existing dependency can create an alert.
  • The graph and alert features need appropriate enablement for the repository. Public-repository defaults differ from private repositories; verify settings instead of assuming every private repository is scanned.
  • An alert identifies the affected package, vulnerable version range, advisory, severity and a patched version when available. A graph inventories packages; it is not itself a vulnerability disclosure database.
  • **SBOM** exports provide a machine-readable component inventory, such as SPDX from the dependency graph. Inventory alone does not prove packages are safe or that runtime exposure is absent.

Security updates and version updates

  • **Dependabot security updates** open pull requests for known vulnerable dependencies where an update is possible, generally aiming for the minimum patched version. A fix may be unavailable or blocked by dependency constraints.
  • **Dependabot version updates** check for newer dependency releases on a configured schedule, including releases unrelated to vulnerabilities.
  • Configure version updates in **.github/dependabot.yml**: top-level **version: 2** and **updates**; each update entry requires **package-ecosystem**, **directory** and **schedule.interval**.
  • **allow**, **ignore**, **groups**, assignees, commit-message settings and rebase behavior customize updates. They do not replace the required ecosystem, location and schedule settings.
  • Review compatibility, release notes and CI results before merging. A Dependabot pull request follows normal repository merge permissions and required checks.
  • An open update pull request does not fix a vulnerability. The alert becomes **fixed** when the affected dependency is removed or upgraded on the default branch; **dismissed** records a separate triage decision.

Review dependency changes before merge

  • **Dependency review** compares dependency changes between revisions in a pull request. Inspect added or removed packages, versions, licenses and newly introduced vulnerabilities.
  • Run **actions/dependency-review-action** on **pull_request** to check changes before merge. Configure vulnerability severity and permitted or denied licenses according to policy.
  • Make the dependency review check **required** through a ruleset or branch protection. A visible warning alone does not enforce a merge block.
  • Use **CodeQL** alongside dependency review when both new source-code defects and dependency or license risks must be assessed. Dependabot update configuration does not replace these checks.
  • Fix or replace vulnerable newly added dependencies before merging. A scheduled dependency update process addresses maintenance; a pull request review gate prevents avoidable new risk.

Code Security and CodeQL 10 to 15%

Extract, analyze and upload

  • **CodeQL** creates a database representing source code and semantic relationships, then runs queries against it. It performs static analysis; it does not rely on executing an exploit.
  • **Default setup** automates supported CodeQL configuration. **Advanced setup** uses an editable workflow in **.github/workflows/** for custom languages, builds, queries and triggers.
  • In an advanced workflow, **checkout** retrieves code, **init** configures extraction, build steps capture applicable compiled code, and **analyze** runs queries and uploads results.
  • Choose **pull_request** for pre-merge analysis, **push** for branch updates and **schedule** for periodic reassessment. A push-triggered workflow must exist in the branch being scanned.
  • For pull requests, **branches** filters the target branch. Event **paths-ignore** can skip documentation-only changes using recursive Markdown and text-file patterns. Skipped required checks can leave merging blocked.
  • A **language matrix** creates separate analysis jobs, commonly in parallel. Set the init **languages** input from **matrix.language** and include every intended supported language.

Build modes and extraction coverage

  • **none** analyzes supported languages without a build. **autobuild** attempts a suitable build automatically. **manual** uses explicit project build commands under CodeQL extraction.
  • For build-based extraction, initialize CodeQL **before** compiling. The database reflects the code built during analysis; a prebuilt binary alone does not provide equivalent source extraction.
  • If **autobuild** fails, inspect logs, install required tools or dependencies, and replace it with explicit build steps. Verify that the intended targets actually compile.
  • **Java/Kotlin** share the **java-kotlin** language identifier. Kotlin requires a build; Java-only no-build analysis does not cover Kotlin.
  • To include **generated source**, run generation and compilation during extraction. Use **manual** mode when explicit build steps are needed to capture the complete Java/Kotlin project.

Query suites, packs and shared configuration

  • **.ql** defines a query; **.qll** supplies reusable query libraries; **.qls** defines a query suite. A suite can use **query** to include specified query files.
  • The **default suite** favors high-confidence security findings. **security-extended** adds broader security queries with lower precision or severity; **security-and-quality** adds reliability and maintainability queries.
  • Use **queries** for additional query or suite references and **packs** for CodeQL packs. A **qlpack.yml** describes a pack; pin **scope/pack@version** for consistent analysis across repositories.
  • Reference a shared CodeQL configuration through **config-file**. Keep language-specific packs mapped to the matching language; authorize access when custom queries live in private repositories.
  • Workflow **queries** or **packs** values replace their counterparts in the configuration file by default. Prefix with **+**, such as **+security-and-quality** or **+scope/pack@1.2.3**, to combine them.
  • Test custom queries with **codeql test run ./tests** on pull requests. Preserve a **non-zero exit code** on failures and do not use **continue-on-error** for a required regression gate.

External CI, SARIF and APIs

  • External CI can install the **CodeQL CLI**, create a database, analyze it and upload results. GitHub Actions is an integration choice rather than the only way to run CodeQL.
  • **SARIF** is the interchange format accepted for third-party code scanning results. Add **github/codeql-action/upload-sarif** after a third-party analyzer generates its SARIF file.
  • The normal CodeQL **analyze** action handles its result upload. Use stable analysis categories for distinct tools or language jobs so results are attributed correctly.
  • The **code scanning REST API** can list alerts, retrieve an alert and update supported alert state fields. Exporters can paginate results and transform JSON to CSV; they do not change query severity through an alert update.
  • For private-repository code scanning operations, classic tokens use **security_events** as applicable. Fine-grained tokens use the relevant **Code scanning alerts** permission; an Actions upload needs **security-events: write**.

Security operations and remediation 15 to 20%

Respond to a leaked credential

  • **Revoke or rotate the exposed credential at its provider first.** Removing code or closing the GitHub alert does not invalidate an active credential.
  • Deploy replacement credentials through a **secret manager** or supported encrypted secret store, update consumers, and investigate possible misuse. Prefer short-lived credentials and identity federation where available.
  • Remove exposed material from current code and address history where necessary. A credential copied outside GitHub remains exposed even after repository cleanup.
  • Close an alert with a documented reason matching the evidence. **Used in tests** means the credential is genuinely test-only; a test filename or nonproduction location is insufficient.
  • Repository administrators manage secret-alert access in **Settings** and can grant eligible people or teams access. Commit authors and authorized recipients may receive notifications; check actual preferences and policies.

Triage code and dependency findings

  • For a code scanning alert, inspect the rule, location, affected branch and explanation. **Show paths** follows data from a source through intermediate steps to a dangerous sink.
  • Validate custom **sanitizers** in context. If they prevent the reported flow, document the evidence and dismiss as **false positive**; improve the model or query when appropriate.
  • **Fixed** means a subsequent relevant analysis no longer detects the issue. **Dismissed** records a deliberate decision, such as false positive, test-only code or accepted risk; viewing an alert does not close it.
  • An ignored finding can leave injection, data exposure or unsafe argument handling exploitable. A dismissal is a risk decision, not a code repair.
  • **CVE** identifies a disclosed vulnerability; **GHSA** identifies a GitHub advisory; **CWE** classifies weakness types. **CWE-79** is cross-site scripting.
  • **CVSS** describes vulnerability severity. **EPSS** estimates near-term exploitation probability. Combine these with reachable code, runtime dependency scope, exposure and fix availability to prioritize work.

Coordinate remediation and reporting

  • **Security campaigns** organize selected alerts around a goal, deadline and owners. For XSS, scope by **CWE-79**; use **autofix:supported** when only Autofix-eligible code alerts should be included.
  • Assign eligible **organization owners or security managers** as campaign managers. Track fixes across repositories and review suggested changes; **Copilot Autofix** suggestions still need validation and tests.
  • Use **Custom** repository Watch settings to select security notifications. **All Activity** is broader; **Participating and @mentions** is insufficient for every security alert.
  • Monitor relevant **webhooks** for alert lifecycle events and integrate them with incident or ticket workflows. Notification delivery depends on access, subscriptions and account preferences.
  • Use a private **repository security advisory** to coordinate disclosure and request a **CVE** when eligible. Repository administrators or other explicitly authorized advisory roles manage that process.
  • Filter bypass-related secret alerts using the qualifier for that dashboard: **secret-scanning.bypassed:true** in the overview and **bypassed:true** in the secret scanning alerts view.

Security administration 10 to 15%

Roll out settings and enforce policy

  • **Security configurations** bundle security feature settings for consistent rollout. Applying a configuration updates selected repositories; setting it as a **default for new repositories** covers future creation.
  • **Default**, **applied** and **enforced** are different decisions. A default alone does not retrofit every existing repository or prevent administrators from changing settings.
  • **Enterprise security policies** establish boundaries across organizations while organization owners continue managing membership and daily collaboration. Restrict repository administrators' ability to disable protected features where required.
  • **Delegated alert dismissal** requires review before an alert can be dismissed. Configure **Prevent direct alert dismissals** and apply an enforced configuration when repositories must retain that control.
  • Keep **bypass approval**, **alert dismissal approval** and **security setting administration** distinct. A team authorized to approve a push exception does not automatically own every security administration task.

Permissions and effective merge controls

  • **Repository admins** enable features and change repository security settings such as code scanning failure thresholds, subject to higher-level policy. **Write access** supports code fixes and management of code scanning alerts.
  • **Security managers** provide organization-wide security management without requiring full organization ownership. Secret scanning access is more restricted than ordinary read access; grant it deliberately.
  • Set code scanning **failure thresholds** for security severity and other findings, then enforce the appropriate required check or **code scanning ruleset**. Threshold configuration alone is not a complete merge policy.
  • **Rulesets** can enforce code scanning and dependency review requirements on selected branches. Confirm enforcement is active, the checks run on the relevant commits, and bypass permissions match policy.
  • On **GitHub Enterprise Server**, site administrators first make licensed security features available, then organizations or repositories enable them within policy. Analysis also requires suitable runners or external CI.
  • **Enterprise Cloud** and **Enterprise Server** can differ in feature support and rollout timing. Match configuration and REST operations to the actual platform; verify effective coverage after deployment.