This condition is most likely caused by worn/leaking cup seals and/or corrosion damage in the bore of the master cylinder. To fix it you can either replace the master cylinder with OEM, or repair your master cylinder with a high quality rebuild kit. You won't know whether your MC is rebuildable or not until you disassemble it to check for heavy pitting/corrosion in the bore.