This isn’t unethical. There are entire companies that do exactly this. If done well, this is actually an extremely valuable service. It would be unethical if you are hired as an employee and outsourced your work, but as a contractor this is fair game.
What? A contractor usually will sign a contract and intellectual property agreements to their name, it's obviously not their right to share company information with a third party.
Subcontracting is not against the rules unless the contract specifically says so. Your job as the prime contractor is to manage the subcontractors so that means IP and privacy concerns etc... Houses are built by subs for example. Defense software is built by subs.
This is still an issue even if you're a contractor! The company should know who has access to their internal resources and codebase. If you are upfront about it, then of course it is fine. Make sure it's in the contract.