LevelUpWith

Explore / GitHub Copilot (GH-300) Exam Prep / Lesson 2

Lesson 2: Ethical AI Use, Potential Harms and Mitigations

[Use GitHub Copilot responsibly] Covers ethical and responsible AI usage and how to identify the potential harms of AI usage, such as bias, insecure code, privacy exposure and over-reliance, along with the mitigation strategy for each.

Free to read, no account needed. Part of GitHub Copilot (GH-300) Exam Prep.

By the end of this level you'll be able to

  • Explain the principles of ethical and responsible AI usage, including fairness, reliability and safety, privacy and security, inclusiveness, transparency and accountability, and apply them to a Copilot workflow
  • Match each potential harm of AI usage to a concrete mitigation, such as human review, tests, security scanning and least-privilege data access
  • Answer scenario questions that ask which mitigation best fits a given harm

Why ethics belongs on a developer exam

Level 1 covered what can go wrong with generative AI: it gets things wrong while sounding sure of itself, it repeats patterns from its training data, and it knows nothing about your business rules. This level covers what you do about those risks. GH-300 frames the answer with Microsoft and GitHub's six principles of responsible AI. You'll see the principles by name, so learn them word for word:

Principle One-line meaning (Microsoft Learn wording) What it looks like in a Copilot workflow
Fairness AI systems should treat all people fairly Check that generated logic doesn't disadvantage some groups of users
Reliability and safety AI systems should perform reliably and safely Tests and review before anything ships
Privacy and security AI systems should be secure and respect privacy Keep secrets and personal data out of prompts; scan generated code
Inclusiveness AI systems should empower everyone and engage people Accessible UI, support for international names and languages
Transparency AI systems should be understandable Say where AI helped, know its limits, keep logs you can audit
Accountability People should be accountable for AI systems The human who accepts the code owns it

Think of Copilot as a fast, well-read junior developer who never says "I'm not sure." You wouldn't merge a junior's pull request without reviewing it, and the same goes for Copilot's suggestions. Each principle below comes with a harm you'll actually run into and a mitigation you can use straight away.

Harm 1: Bias → diverse test data and human review

You type a comment and accept the suggestion:

# validate a customer's full name
import re

def is_valid_name(name: str) -> bool:
    # Copilot suggestion: looks tidy, but only allows A-Z letters and spaces
    return bool(re.fullmatch(r"[A-Za-z ]+", name))

This rejects Zoë, O'Brien, José and Nguyễn. Nothing crashes, but you've quietly shut out real customers. That breaks fairness and inclusiveness. The model picked up a common pattern from its training data, and common is not the same as correct.

Mitigation: write tests that cover a wide range of inputs, and review with your actual users in mind.

import pytest

# Names from different languages and cultures. All of them must pass.
@pytest.mark.parametrize("name", ["Zoë Smith", "Seán O'Brien", "José Álvarez", "Nguyễn Văn An", "Anne-Marie Lee"])
def test_accepts_international_names(name):
    assert is_valid_name(name)

Run it. When it fails, you've caught the bias before your customers do.

Harm 2: Insecure code → security scanning and safe patterns

// Copilot suggestion: works in the demo...
app.get("/user", async (req, res) => {
  const rows = await db.query(`SELECT * FROM users WHERE id = '${req.query.id}'`); // SQL injection!
  res.json(rows);
});

// ...the reviewed version: a parameterised query, where the driver escapes the input
app.get("/user", async (req, res) => {
  const rows = await db.query("SELECT * FROM users WHERE id = $1", [req.query.id]);
  res.json(rows);
});

Plenty of public code builds SQL by string concatenation, so the model will suggest it too. This is a reliability and safety and privacy and security harm.

Mitigation: human review that includes a security checklist, plus automated security scanning (static analysis such as code scanning, and secret scanning) in CI, so a tired reviewer isn't your only defence.

Harm 3: Privacy exposure → least-privilege data access

Copilot builds its prompt from the code around your cursor, which can include other open files. If config/secrets.json or a folder of customer data is part of that context, it can end up in the prompt.

Mitigation: give the AI access only to what it needs. On GitHub.com, a repository admin sets content exclusion under Settings → Copilot → Content exclusion, listing paths in the "Paths to exclude in this repository" box:

# Ignore one specific file in this repository
- "/config/secrets.json"
# Ignore every file whose name starts with "secret", anywhere
- "secret*"
# Ignore everything in or below /customer-data
- "/customer-data/**"

Gotcha: GitHub's docs say Copilot CLI and Agent mode in Copilot Chat in IDEs do not support content exclusion, and changes can take up to 30 minutes to reach IDEs. Exclusion lowers the risk; it doesn't replace keeping secrets out of the repository altogether. A later level covers exclusions in depth.

Harm 4: Over-reliance → keep the human in the loop

The quietest harm is losing your own skills. You start tabbing through suggestions without reading them, and juniors stop learning why the code works. That undermines accountability: you can't own code you don't understand.

Mitigations:

  • Read every suggestion before accepting it. If you can't explain a line, don't merge it.
  • Write the test (or at least the assertions) yourself, so you set the requirement and Copilot doesn't get to define "correct".
  • In pull request review, expect the author to explain AI-assisted code just like any other code.

Harm 5: Matching public code → the public code filter

Now and then a suggestion closely matches code in a public repository, which may carry a licence. Copilot's settings let you block suggestions matching public code. If you allow them instead, code referencing shows you the match, the repositories it appears in and any licence detected. This mitigation is for licensing and IP risk. It does nothing about bias or over-reliance, which is a classic exam distractor.

Transparency and accountability in practice

  • Transparency: be open about where AI helped (for example, a line in the PR description), and be honest about what the tool can't do.
  • Accountability: Copilot isn't a team member who can be held responsible. The developer who accepts the code and the team that merges it are accountable for it.

Quick reference: harm → mitigation

Harm Best-fit mitigation
Bias / unfair outputs Diverse test data, human review
Insecure code Security scanning, secure patterns, review
Privacy exposure Least-privilege access: content exclusion, no secrets in prompts or repos
Over-reliance Human in the loop, write tests yourself, explain before merge
Public code / licensing Block or review suggestions matching public code

What the exam asks about this

Expect short scenarios: "A suggestion does X. Which principle is at stake?" or "Which mitigation best fits?" The trick is to pick the mitigation that targets that harm. Tests and review for correctness and bias, scanning for security, exclusion for privacy, the public code filter for licensing. Also learn the six principle names exactly as Microsoft writes them.

Key takeaways

  • The six principles are fairness, reliability and safety, privacy and security, inclusiveness, transparency, accountability.
  • Every harm has a matching mitigation. Match them precisely, not loosely.
  • Content exclusion limits what Copilot can read, but it doesn't cover Copilot CLI or agent mode.
  • The public code filter deals with licensing risk, not bias or security.
  • People, not Copilot, are accountable for the code they accept.

A 6-question knowledge check follows this lesson in the app, free and without an account.

Keep going: levels 3 and 4 are free

Create a free account to open the next two levels, save your progress and pick up where you left off. No card needed.

Next: Level 3, Validate AI Output and Operate Copilot Responsibly.

Create a free account →See the whole course

More like this

  • Microsoft Cloud and AI Security Engineer (SC-500) Exam Prep

    Get ready to pass Microsoft SC-500 (Implementing End-to-End Security Controls for Cloud and AI Workloads) by learning every bullet in Microsoft's study guide.…

    Exam prep · SC-500 · IT Support, Networking & Security · Expert · 60 levels · 4 free · Professionally curated by levelupwith.com

  • Microsoft Azure DevOps Engineer Expert (AZ-400) Exam Prep

    Prepare for Microsoft AZ-400 with practitioner-led levels that cover every skill in Microsoft's study guide (skills measured as of July 27, 2026), weighted as…

    Exam prep · AZ-400 · Cloud & Compute · Expert · 58 levels · 4 free · Professionally curated by levelupwith.com

  • Microsoft Azure Fundamentals (AZ-900) Exam Prep

    Learn to pick the cloud model, service type or Azure service that fits a scenario and explain why the alternatives do not, across every skill in the 20 July 20…

    Exam prep · AZ-900 · Cloud & Compute · Capable · 17 levels · 4 free · Professionally curated by levelupwith.com

  • Microsoft Azure Administrator (AZ-104) Exam Prep

    Work through every bullet of the AZ-104 skills measured as of April 17, 2026, learning each task in the Azure portal, Azure CLI, PowerShell, and ARM templates…

    Exam prep · AZ-104 · Cloud & Compute · Expert · 60 levels · 4 free · Professionally curated by levelupwith.com

  • Support Pro: Helping Users Move to Microsoft 365

    Help users get through a move from Google Workspace to Microsoft 365, from the week before cutover to the first tickets afterwards. You will learn what moves a…

    Course · Microsoft · Suite Support Pro: Configure and Fix · Expert · 40 levels · 4 free · Professionally curated by levelupwith.com

  • Microsoft 365 Support Pro: Copilot for End Users

    Learn to work out which Copilot a user actually has, and to fix the everyday Copilot tickets: missing buttons, licence and sign-in problems, files Copilot can'…

    Course · Microsoft · Suite Support Pro: Configure and Fix · Expert · 36 levels · 4 free · Professionally curated by levelupwith.com