Common Misconfigurations
- Using HTTP instead of HTTPS for package indexes
- Trusting unverified package sources
- Not using package signing verification
- Allowing arbitrary index URLs
- 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 allpip 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 tellpip 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 inpip.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-hostin production. - Configure index URLs in
pip.conf, not inrequirements.txtfiles. - Implement package signing where possible.

