Protecting your IP starts with evaluation of high-quality outsourcing companies. Look for offices that are professional and secure, with the standard security measures that any respected Western office would offer. Verify digital security practices, including firewall, VPN, and encryption technology that should be standard for any software developer.
Your risk is directly related to just how much IP you expose. Using common technologies and practices to build your unique software carries a low risk, as the bones of your engagement are already widely available to all. Building software that requires unique algorithms or coding research only your company has access to, on the other had, can lead to high exposure when outsourcing, and can put your IP at risk. The benefits of outsourcing are still high when risk is at its highest, but consider engaging multiple teams to partition your product.
The right outsourcing prime contractor will follow through on every step of your outsourcing process and ensure that your IP is protected to the maximum extent possible. Your prime contractor will know what security measures to look for, and will diminish the risk to your IP immensely.