Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Security Basics  ›  Capstone Project

Vet Every Dependency

Security Best Practices 15 minBefore installing any package an assistant suggests, confirm that it really exists, is trustworthy and is actually needed, and pin the version you reviewed.

Vet Every Dependency

Suppose the assistant's code for splitting amounts begins with pip install rupee-split-pro. The name sounds reasonable and the install line looks routine. But a package is code written by strangers that will run with all of Kitty's permissions, and the assistant may have suggested it from a pattern rather than from knowledge that it exists and is trustworthy.

The rule

Before installing a suggested package, confirm it exists, is trusted and is needed.

A dependency is someone else's package that your project installs and runs. Assistant-suggested dependencies carry particular risks:

  • Invented names. An assistant can suggest a package name that sounds right but does not exist. Attackers have been known to register plausible invented names and fill them with harmful code, waiting for someone to install them.
  • Look-alike names. A name one letter away from a popular package, published to catch typing slips.
  • Stale knowledge. An assistant may suggest an old version, or a package that has since been abandoned or found to have security problems.
  • No need at all. A whole library for something your language already does. Python's built-in decimal module handles exact money arithmetic, and Kitty's own tested split function is a dozen lines.

For each package that passes, pin the version you reviewed in your requirements file, and check your dependencies for published security advisories from time to time, so an unreviewed release cannot slip in unnoticed.

The shortcut

Three checks, and any "no" means do not install: Exists? It is on the official package index under exactly that spelling, with a real history. Trusted? It is widely used, maintained, documented and links to its source code. Needed? The standard library or an existing dependency cannot already do the job.

Vetting rupee-split-proStep 1 of 4
  1. Needed?

    Kitty already has a tested split_evenly, and decimal covers exact money arithmetic. Already a likely no.

This lesson closes the course's safety checks. Before you share Kitty with anyone, run all four from this section: no secrets in code, history or prompts; every input checked, parameterised and escaped; every request checking what the user may do; and every dependency existing, trusted and needed.

Drills

Answer fast — trust the rule.

quick drill

An assistant suggests a package you have never heard of. What do you check first?

quick drill

Why are invented package names dangerous?

quick drill

Kitty needs exact decimal arithmetic for money. What is the best option?

quick drill

Why pin the versions of your dependencies?

Remember

  • Rule: before installing a suggested package, confirm it exists, is trusted and is needed.
  • Shortcut: exists, trusted, needed. Any "no" means do not install.
  • Trap: a plausible name and a routine-looking install line. Before sharing, run all four security checks.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainThe pre-ship review

Before sharing Kitty with other flats, you run one last security review. Explain what you would check for secrets, input, access control and dependencies, giving one concrete Kitty example for each.