Module 08 · Lesson 8.4
Dependency Vulnerabilities
On this page
- What you will learn
- What a dependency vulnerability is
- Step 1: know what you use
- Step 2: run a dependency audit and read the report
- Step 3: prioritise with reasons, not only scores
- Step-by-step workflow
- Using an AI assistant on dependency advisories
- Conclusion and your next step
- Reusable prompt
- Expected output
- Common errors and fixes
- Validation checklist
- Hands-on exercise
- Knowledge check
- Frequently asked questions
- References
A car maker sends a recall notice: some models have a faulty brake part. You do not scrap the car in a panic. You check three things. Does my car have that part? Is the part used in the way the notice describes? How risky is it for me? Then you book the repair. Library advisories work the same way.
In this lesson you list the libraries behind the fictional Tidewell Wholesale service, run a real audit tool, and judge each advisory against how the code uses the library. You also practise the reasoning on made-up advisories, clearly labelled. A severity score is one input, not the answer.
What you will learn
- List the direct and indirect libraries of a project, with exact versions.
- Run an audit tool and read its report, and know where advisories come from.
- Judge an advisory by whether your code reaches the weak part with input an outsider controls.
- Rank advisories and plan the upgrade in stages, with proof that the report is clean afterwards.
Before you start
- You finished Input Validation and Injection, or you have a project with a dependency list.
- You can run
pipand Python 3.11 or newer in a scratch environment. - You know the staged approach from Dependency Upgrades and Migrations.
What a dependency vulnerability is
- Dependency
- A library your code uses instead of writing the part itself. It is a ready-made part in your machine. If the part is faulty, your machine is affected.
- Direct and indirect dependency
- A direct one is a library you chose. An indirect one is a library that your library needs. It is a part inside a part. You did not pick it, but you still run it.
- Pinned version and lock list
- A pin names the exact version, such as
requests==2.31.0. A lock list pins every library, direct and indirect. It is a recipe that names exact brands. - Advisory
- A public notice about a weakness in named versions of a library, usually with the version that fixes it. It is the recall notice.
- Advisory ID
- A catalogue number, such as CVE-… , GHSA-… or PYSEC-…. One weakness can have several numbers from different catalogues. They are aliases of each other.
- CVSS score
- The Common Vulnerability Scoring System gives a weakness a number from 0 to 10 for how severe it is in general. It is a hazard label on the box. It knows nothing about your shop.
- Reachable
- Your code actually calls the weak part, in the situation the advisory describes. A faulty brake part in a car that has no such brakes is not reachable.
Why not upgrade everything at once? Because upgrades can break things, and a team has limited time. The skill is to find the few advisories that matter now, and to plan the rest.
Step 1: know what you use
You cannot check what you cannot list. In the scratch repository, the file the team edits is short.
requests==2.31.0The direct dependency list of the scratch repository.
That is one library. But requests needs others. To see everything that is installed, ask pip. This was run in a clean scratch environment, after installing only requests==2.31.0.
python -m pip freezeList every installed library with its exact version.
certifi==2026.10.23
charset-normalizer==3.5.2
idna==3.20
requests==2.31.0
urllib3==2.8.0One library you chose, four you did not. Save this list as the lock list of the project, with the date. A real Django service has dozens of lines. Some teams use tools such as pip-compile or Poetry to keep a lock file, so that every machine installs the same versions.
Step 2: run a dependency audit and read the report
Advisories are kept in public databases. OSV (opens in a new tab) collects them for many languages. GitHub publishes its own and sends alerts through Dependabot alerts (opens in a new tab). The Python Packaging Authority keeps one for Python. A tool such as pip-audit (opens in a new tab) checks your list against these sources.
pip-audit -r requirements.lock --no-deps --disable-pip --progress-spinner off 2>/dev/nullAudit a pinned list. The warnings go to the error stream and are left out here.
Name Version ID Fix Versions
-------- ------- --------------- ------------
requests 2.31.0 PYSEC-2026-1873 2.32.0
requests 2.31.0 PYSEC-2026-1872 2.32.4
requests 2.31.0 PYSEC-2026-2275 2.33.0
requests 2.31.0 PYSEC-2026-1873 2.32.0
requests 2.31.0 PYSEC-2026-1872 2.32.4
requests 2.31.0 PYSEC-2026-2275 2.33.0The tool printed each row twice here, so read it as three distinct advisories for requests 2.31.0. Their fix versions are 2.32.0, 2.32.4 and 2.33.0. Results change as new advisories are published, so your run on another day will differ.
Judge each advisory with three questions
- Is the weak part reachable? Read the advisory text. Which function or situation does it name? Search your code for it.
- Can an outsider control the input? If the weak part needs a crafted value, where does your code get that value? From a customer, a partner, or your own constant?
- Is a fix available, and what does the upgrade cost? If there is a fixed version, how big is the jump? If there is none, is there a workaround?
Now apply them to the real report. Each row below paraphrases the text printed by the tool for that advisory. Open each ID on OSV to read the whole notice, because a short summary can leave out detail.
| Advisory | What its text says | What to search for |
|---|---|---|
| PYSEC-2026-1873 (alias CVE-2024-35195) | Applies when a requests.Session first makes a request to a site with verify=False. Certificate checks may then stay off for later requests to that site. | Session, verify= |
| PYSEC-2026-1872 (alias CVE-2024-47081) | Specially crafted URLs may leak credentials from a .netrc file. A workaround is trust_env=False. | Where URLs come from; use of .netrc |
| PYSEC-2026-2275 (alias CVE-2026-25645) | Concerns the function extract_zipped_paths(). The text says that standard use of the library is not affected, and only code that calls this function directly is. | extract_zipped_paths |
git grep -nE "Session|verify=|extract_zipped_paths|netrc" -- "*.py"
echo "exit code: $?"Search our own code for those names. Exit code 1 from Git means no match.
exit code: 1git grep -nE "^import requests|requests\.(get|post)" -- "*.py"And where do we use requests at all?
dispatch/importers.py:2:import requests
dispatch/importers.py:14: response = requests.get(PARTNER_URL, headers=headers)Our code uses requests.get once, in the EDI importer. It does not use a Session, it does not switch off certificate checks, and it does not call extract_zipped_paths. The address it calls is a constant in the code, not a value from a customer. So, from the text of the three advisories, none looks reachable from this repository.
Two things remain open. A server may hold a .netrc file, which is a question for whoever runs the servers. And another library may call requests inside itself, which a search of your own code cannot see.
That is a judgement, written down with its evidence. The fix is still cheap, so you plan the upgrade. The point is that you chose the urgency yourself, with reasons. Notice also that verify=False appears in the first advisory. Lesson 8.5 shows an assistant suggesting exactly that.
Step 3: prioritise with reasons, not only scores
To practise the ranking, here is a set of made-up advisories. The IDs, the package names and the scores are invented for this lesson. None of them is real, and nothing with these names should be installed. The script ranks them with three plain rules.
- Not reachable: LOW. Upgrade in routine work.
- Reachable, and the input comes from outside (a customer or a partner): URGENT.
- Reachable, but the input is only our own data: SOON.
# Every advisory and package here is MADE UP, to practise the reasoning.
ADVISORIES = [
{"id": "EXAMPLE-2026-0001", "package": "example-edi-parser (made-up)",
"score": 9.1, "bad_function": "parse_huge_file", "fix": "3.2.1"},
{"id": "EXAMPLE-2026-0002", "package": "example-pdf-toolkit (made-up)",
"score": 7.5, "bad_function": "merge_documents", "fix": "1.4.0"},
{"id": "EXAMPLE-2026-0003", "package": "example-csv-helper (made-up)",
"score": 5.3, "bad_function": "read_rows", "fix": None},
]
# What a search of our own code found: functions we call, and who supplies the input.
USES = {
"example-edi-parser (made-up)": {"calls": {"parse_file"}, "input": "partner"},
"example-pdf-toolkit (made-up)": {"calls": {"merge_documents"}, "input": "our own data"},
"example-csv-helper (made-up)": {"calls": {"read_rows"}, "input": "partner"},
}
OUTSIDE = {"partner", "customer"}
def assess(advisory):
use = USES.get(advisory["package"])
if use is None or advisory["bad_function"] not in use["calls"]:
return 3, "LOW", f"we never call {advisory['bad_function']}; upgrade in routine work"
if use["input"] in OUTSIDE:
how = "upgrade now" if advisory["fix"] else "no fix yet: limit and check the input"
return 1, "URGENT", f"we call {advisory['bad_function']} on {use['input']} input; {how}"
return 2, "SOON", f"we call {advisory['bad_function']} but only on {use['input']}; plan the upgrade"
rows = sorted((assess(a) + (a,) for a in ADVISORIES), key=lambda r: (r[0], -r[3]["score"]))
for rank, (_, label, reason, advisory) in enumerate(rows, start=1):
print(f"{rank}. {advisory['id']} score {advisory['score']} {label}")
print(f" {advisory['package']}: {reason}")A made-up example. The facts in USES come from searching your own code.
What each part does
ADVISORIESholds three invented notices, each with a score, the weak function and a fixed version (or none).USESrecords what a search of our code found: which functions we call, and who supplies the input.assessapplies the rules and returns a rank, a label and a reason.- The last lines sort by rank first and score second, then print.
python triage.pyRun it.
1. EXAMPLE-2026-0003 score 5.3 URGENT
example-csv-helper (made-up): we call read_rows on partner input; no fix yet: limit and check the input
2. EXAMPLE-2026-0002 score 7.5 SOON
example-pdf-toolkit (made-up): we call merge_documents but only on our own data; plan the upgrade
3. EXAMPLE-2026-0001 score 9.1 LOW
example-edi-parser (made-up): we never call parse_huge_file; upgrade in routine workThe advisory with the highest score, 9.1, comes last. Our code never calls the weak function. The one with the lowest score, 5.3, comes first. We call its function on partner files, and no fix exists yet, so the work is to limit and check the input. This is why a score is an input and not the answer.
| Signal | Raises the priority | Lowers the priority |
|---|---|---|
| Reachability | Your code calls the named function | You never call it |
| Input source | A customer or partner supplies the value | Only your own constants or staff do |
| Exposure | The service faces the internet | It runs only inside a private network |
| Fix | A fixed version exists and the jump is small | No fix, or a big jump that needs a plan |
| Impact | Data theft, code running on your server | A crash of one request |
Step-by-step workflow
Step 1: Make the inventory
List direct and indirect libraries with exact versions, from the build that runs in production. Record the date and the commit.
What you should see: A lock list with a date.
Step 2: Run an audit tool
Run a tool such as pip-audit, and read the advisory sources it uses. Keep the raw report.
What you should see: A report with advisory IDs and fix versions.
Step 3: Read each advisory
Open the full text on OSV or the vendor page. Note the weak function or situation, the affected versions and any workaround.
What you should see: One line per advisory: what must be true for it to hurt you.
Step 4: Search your code and ask who controls the input
Search for the named function or setting. Find where its input comes from. For things a search cannot show, such as a file on a server, write a question and an owner by role.
What you should see: A judgement per advisory with evidence, and a list of open questions.
Step 5: Rank and plan the upgrade in stages
Order by reachability, input source and fix cost. Make upgrades small, with tests before and after, as in Module 6. Use a workaround for anything with no fix.
What you should see: A ranked list, and a staged plan for the top items.
Step 6: Prove the result and repeat
After the upgrade, run the audit again. Then schedule it, so that new advisories reach you. Dependabot alerts or a scheduled build do this.
What you should see: A clean or explained report, and a repeat schedule.
- Inventory
Direct and indirect
- Audit
Advisory IDs
- Read
What must be true
- Reach and input
Search, ask who controls
- Rank
Score is one input
- Staged upgrade
Then audit again
Each stage removes some advisories from the urgent list.
Here is the proof step on the scratch environment. After installing requests==2.33.0, which is the highest fix version in the report, the audit was run again.
python -m pip freeze
pip-audit -r requirements.upgraded.lock --no-deps --disable-pip --progress-spinner off 2>&1 | grep -v WARNINGFreeze the upgraded environment, then audit it.
certifi==2026.10.23
charset-normalizer==3.5.2
idna==3.20
requests==2.33.0
urllib3==2.8.0
No known vulnerabilities foundIn a real project, you do not stop here. You run the test suite, run an import against a fake partner, and release in a way you can undo. Dependency Upgrades and Migrations covers that.
Using an AI assistant on dependency advisories
An assistant can explain an advisory in plain words and suggest what to search for. Give it the advisory text and the lines of your code that use the library. Do not ask it to say whether you are affected from the library name alone.
- It may invent details. It may state a CVSS score, a fixed version or an affected function from memory. Check every one against the advisory page.
- It may know old facts. Advisories appear every day, and its knowledge stops at a date. Use the audit tool for what exists now.
- It may recommend a package that does not exist. Check any new package name on the package index before you install it.
- Ask for questions, not verdicts. 'What must be true for this to affect us?' is more useful than 'are we safe?'.
Conclusion and your next step
You can now list what a project depends on, run an audit, and judge an advisory by reachability and who controls the input. You saw that a score of 9.1 can rank below a 5.3. You also proved an upgrade with a second, clean audit run.
Your next step: check code that was written by a machine. Continue with Reviewing AI-Written Code for Security, where an assistant fixes one finding and creates new problems on the way.
For more, read Dependency Upgrades and Migrations and the module overview Security Review and Hardening.
Reusable prompt
Advisory reachability questions
Turns an advisory and the lines of code that use the library into questions you can check, not a verdict.
Help me judge whether a library advisory affects my code. The company and code are fictional. Use ONLY the text below. Do not state scores, versions or functions that are not in it.
Advisory text (summarised from the advisory page): The function extract_zipped_paths() uses a predictable file name when it extracts files into the temporary directory. A local attacker with write access to that directory could place a malicious file. Standard use of the library is not affected. Only code that calls this function directly is.
How my code uses the library: one call, requests.get(PARTNER_URL, headers=headers), in a background worker. PARTNER_URL is a constant. A search for extract_zipped_paths found nothing.
Please give me:
1. What must be true for this advisory to affect my code.
2. Which of those conditions my facts already rule out, and which they do not.
3. The questions I still need to ask, and who might know.
4. What I cannot judge from this text.
Mark any guess as (unverified).Show the reusable template
Replace each {{placeholder}} with your own details.
Help me judge whether a library advisory affects my code. Use ONLY the text below. Do not state scores, versions or functions that are not in it.
Advisory text (copied or summarised from the advisory page): {{advisory_text}}
How my code uses the library: {{usage_facts}}
Please give me:
1. What must be true for this advisory to affect my code.
2. Which of those conditions my facts already rule out, and which they do not.
3. The questions I still need to ask, and who might know.
4. What I cannot judge from this text.
Mark any guess as (unverified).Expected output and limitations
A short list of conditions, a split between conditions ruled out and conditions still open, questions with likely owners, and an honest list of what the text cannot show. It should not invent scores or versions, and it should not say 'you are safe'.
What must be true
1. The code calls extract_zipped_paths() directly, or a library you use does.
2. A local attacker can write to the temporary directory of the machine.
Ruled out by your facts
- Direct call: your search found none.
Still open
- Whether another library calls the function internally. Ask: does any dependency list show a library that wraps requests?
- Who can write to the worker's temporary directory. Ask the person who runs the servers.
Cannot judge
- Anything not in the advisory text, including scores and other affected versions.
- (unverified) Whether an upgrade changes other behaviour you rely on.Limitations to keep in mind
- The assistant sees only the text you paste. It cannot see your indirect libraries or your servers.
- It may add details from memory, such as a score. Check them against the advisory page.
- It may be out of date about advisories. Use the audit tool for the current list.
- Sending code is sharing. Do it only with a tool and account your policy allows.
Common errors and how to fix them
Treating the severity score as the priority
Why it happens: The number is simple, and the report is sorted by it.
Fix: Use the score as one input. Add reachability, who controls the input, exposure and the cost of the fix.
Upgrading everything at once to clear the report
Why it happens: A long list feels urgent.
Fix: Rank first. Upgrade in small, tested stages, and keep a way back.
Auditing once and never again
Why it happens: A clean report felt final.
Fix: New advisories appear every day. Schedule the audit, or turn on alerts, and record the date of each run.
Validation checklist
Tick each item once you have confirmed it.
Hands-on exercise
Audit one project and judge two advisories
In a project you may check, make an inventory, run an audit tool, and judge at least two advisories against how your code uses the library. Write a short ranked list.
You will need
- A project with a dependency list or lock file, and its commit hash.
- An audit tool such as pip-audit, or the equivalent for your language.
- The full text of the advisories you choose, from OSV or the vendor.
Acceptance criteria
Your work is done when every one of these is true.
Hints (3)
- If the report is clean, say so, and also say which sources the tool used and on what date.
- If an advisory has no fix, write down a workaround or a way to limit the input.
- You can practise on a scratch environment that pins an older version of one library.
Show a model answer
A strong answer starts with a dated lock list and the raw report. For two advisories it quotes the ID and the fixed version exactly, summarises what must be true for harm, and shows the search that was run and its result. It marks one as probably unreachable, with the open question that remains, and ranks another higher because the input comes from outside. It plans the upgrade in small stages, with tests, and runs the audit again. A weak answer lists the report sorted by score and says 'upgrade everything'.
Knowledge check
Choose an answer, then check it. Nothing is recorded — this is for you.
Show the answer and explanation
Answer: B. A score describes the weakness in general, not your use of the library. If your search shows the function is not called, the urgency is low. Ignoring it forever is the other mistake: keep the note, because code changes and the library should be upgraded in normal work.
Show the answer and explanation
Answer: B. A tool only knows published advisories, and only for the versions you gave it. New ones appear after you ship. 'No vulnerabilities' claims more than the report can show.
Show the answer and explanation
Answer: B. Assistants sometimes name packages that do not exist, and attackers can register such names. Asking the assistant repeats the same guess. Check the index yourself.
Frequently asked questions
What is the difference between a direct and an indirect dependency?
A direct dependency is a library you chose and listed. An indirect one is a library that your library needs. You still run its code, so an advisory for it can matter to you.
What is CVSS, and should I trust the number?
CVSS is a scoring system that rates how severe a weakness is in general, from 0 to 10. Use it as one input. It does not know how your code uses the library, who can reach it, or how easy the fix is.
How often should I audit my dependencies?
Run an audit in every build, and turn on alerts from your hosting platform if you have them. New advisories are published every day, so a clean report today says nothing about next week.
What if there is no fixed version yet?
Look for a workaround in the advisory, such as a setting. Limit and check the input that reaches the weak part. Watch for the fix, and write the decision down with a date to review it.
- Written by
- PromptFable Editorial
- Last updated 19 Nov 2026
- Review
- Reviewed by Waseem Nadir, Technical Reviewer
- Last reviewed 27 Nov 2026
References
Primary sources for the technical details in this lesson. Vendor platforms change — check the official page if anything here looks different from what you see.
- GitHub - pypa/pip-audit(opens in a new tab)
Python Packaging Authority · Official documentation · The audit tool used in this lesson.
- OSV - Open Source Vulnerabilities(opens in a new tab)
OSV · A public database of advisories for many languages.
- Common Vulnerability Scoring System SIG(opens in a new tab)
FIRST · Official documentation · The owner of the CVSS standard.
- Dependabot alerts - GitHub Docs(opens in a new tab)
GitHub · Official documentation
- Secure Software Development Framework | CSRC(opens in a new tab)
NIST · Official documentation · Practices that include checking third-party components.
PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.