Dear Habil,
Although you have classified your question under the title of "safety and health of employees, but, your question, "who is direct responsible" is not clear with what respect you have asked about the responsibility, whether for the purpose of compensation to the injured worker or the health hazards of the worker.
In fact, there are two different aspects of the case, i.e., (1) liability/ responsibility for the purpose of compensation to the worker under the provisions of workman's Compensation Act, or (2) responsibility for the purpose of safety and health of the workers.
For the purpose of compensation, his contractor employer is responsible for payment under the WC Act, or as per the provisions of the agreement entered in to with the principal, if the principal employer has to bear the cost.
So far as the responsibility for the safety and health of the worker is concerned, there being the premises of the pricipal, it is the direct responsibility of the principal employer to maintain well. Even if there is any laxity on the part of the principal employer having failed to maintain building gate properly, the part of his working premises, even a criminal case can be registered by the police against the principal employer for his negligence, which caused serious injury to the worker.
However, if considered on ethical and moral grounds, the principal employer must take all steps, including necessary expenses, to compensate the contract worker, besides getting him recovered soon.