Short answer. Under Article 1652, a landlord can collect from the subtenant only up to the amount of rent the subtenant himself owes under the sublease at the time of the landlord's extrajudicial demand. The subtenant's liability is subsidiary and capped at what he owes his own lessor, not the whole of the main tenant's debt.
What the law says
the sublessee shall not be responsible beyond the amount of rent due from him, in accordance with the terms of the sublease, at the time of the extra-judicial demand by the lessor
Civil Code, Article 1652 — The Sublessee's Liability to the Owner. Read the full provision →
The subtenant's liability is subsidiary
Article 1652 lets an owner reach the subtenant, but only in a secondary way. It provides that The sublessee is subsidiarily liable to the lessor for any rent due from the lessee. "Subsidiary" means the subtenant is not the primary debtor for the main tenant's rent; the landlord looks to him only for the main tenant's unpaid rent, and only to the extent the article allows. The subtenant never signed a lease with the owner, so the law does not turn him into a full guarantor of everything the main tenant owes. His exposure is carefully bounded, as the next rule makes plain.
The cap: only what the subtenant himself owes
The key limit is on amount. The article states that the sublessee shall not be responsible beyond the amount of rent due from him, in accordance with the terms of the sublease, at the time of the extra-judicial demand by the lessor. So the ceiling is the subtenant's own rent obligation under the sublease, measured as of the landlord's demand. If the subtenant owes his own lessor a smaller sum than the main tenant owes the owner, the owner can reach only that smaller sum. The subtenant cannot be made to pay more to the owner than he was going to pay under his sublease anyway.
Advance payments may not count
There is a trap for subtenants who pay early. The article provides that Payments of rent in advance by the sublessee shall be deemed not to have been made, so far as the lessor's claim is concerned, unless those advance payments were made in virtue of the custom of the place. This prevents a subtenant and main tenant from defeating the owner's claim by arranging prepayments. As against the owner, an advance payment may be disregarded, so the subtenant could still owe the owner even though he already paid the main tenant. The safe course is to be cautious about paying rent ahead of schedule.
What this does and does not give the owner
This remedy gives the owner a limited, extra source of recovery, not a windfall. It reaches only the subtenant's own rent, fixed at the moment of extrajudicial demand, which is why making a clear, timely demand matters to the owner. It does not make the subtenant answerable for damages, penalties or the full arrears of the main tenant beyond that capped amount, and it does not disturb the owner's separate rights against the main tenant himself. For the subtenant, the comfort is that his worst-case exposure to the owner is essentially the rent he already owed under his sublease.