Some points to raise with your management and sorry for you.
>I'm not sure ethically
Better be sure legally.
1. Is the risk worth company reputation ?
2. The client is buying 'company' if nothing else there, client will be 'frustrated' for cheating them. How hard is to build new relations ? Does it cost more than the profit from the project ?
3. The 'company' is at mercy of vendor for not showcasing the work done.
This seems completely normal. Every small agency I know does this.
Honestly, this is something you shouldn't even spend time thinking about. As icedchai already pointed out, it's "completely normal" and I'll add it's also ethical.
Instead of fretting about the ethics of who gets credit you might consider how you could work this to your advantage, because it could be you can.
I've subcontracted work most all my life and still do. It's allowed me to work from home wherever I wanted home to be, and work whatever hours I want.
And here's a few things to consider... I don't care if I get "credit". I only care if I get paid or not. If I make my clients look good they keep sending me work. I don't care how much they charge.
Because I'm pretty good at what I do I can bill what I want. A job that might take other's over a month I might be able to do in a week and bill for the month. I can do this because I have a lot of boilerplate code and know what tools to use for the job.
If I have neither of those I can factor in the time needed to find and learn how to use the tools I need and bid a fair rate for that. In that case I get paid to learn.
The tricks to making that work are being good at what you do, being honest about what you do not know, and having a solid understanding of what it takes to learn what you don't know.
One last thing... ultimately the company you subcontract from is on the hook to deliver the product. That is their main responsibility. If you blow it they still have to deliver it.
That's why they get paid the "big bucks" and get all the credit.