Riposte counter-attack takes into account the entire damage done to the hero with direct attacks.
So if the hero with the counter-attack buff also had their defense lowered, they’ll counterattack more damage (as they’re taking more damage). Same thing happens if the attacker increased their attack, and hits a hero with riposte.
Do note that burn/poison/etc. damage is not countered. If it activates Pierce talent from the Ranger class also prevents counter-attacks and reflect buffs from working