On the eve of Mid-Autumn Festival, some people will go to great lengths to get mooncakes, the traditional gift for family, friends and colleagues. At Alibaba Group Holding Ltd., four engineers tried to rig the distribution system of the e-commerce giant’s mooncake selloff—and were fired for their effort.

Alibaba confirmed it fired the four this week, after they hacked into the internal website that allows employees to purchase the company’s signature mooncakes, with an orange fluffy Alibaba mascot inside. The Hangzhou-based...