Skip to main content

Common Misconfigurations

  1. Using HTTP instead of HTTPS for package indexes
  2. Trusting unverified package sources
  3. Not using package signing verification
  4. Allowing arbitrary index URLs
  5. Missing SSL certificate verification

Vulnerable Example

Secure Solution

Key Commands for Managing Indexes

These commands allow you to view, set, and use secure index configurations.

1. View Current Configuration

This command shows you all pip settings, including the index-url and cert files it’s currently using.

2. Set Secure Index (Globally)

This is the recommended way to set your company’s private repository (like Nexus or Artifactory) for all projects.

3. Set Custom Certificate

If your private repository uses a self-signed or internal company certificate, you must tell pip where to find it.

4. Insecure Flags (To Avoid)

Never use these flags in production. They expose you to Man-in-the-Middle (MITM) attacks.

5. Secure Install (With Custom Cert)

If you haven’t set the certificate in pip.conf, you can provide it at install time. This is common in CI/CD scripts.

Best Practices

  • Always use HTTPS for package indexes.
  • Enable hash verification for production.
  • Use private package repositories with proper SSL.
  • Never use --trusted-host in production.
  • Configure index URLs in pip.conf, not in requirements.txt files.
  • Implement package signing where possible.