Most were waiting on Indonesia's Nunaken island, which is just south of Malaysia's Sabah state, for permission to return to Malaysia to work legally.
In 2002, the last time Malaysia launched a crackdown on illegal workers, about 25,000 Indonesians crowded on to the island.
At least 30 died from diseases in the cramped and unsanitary conditions.
Local Indonesian Red Cross chief Mesdiono on Friday said about 7650 workers were living in 32 camps on the island.
"We have treated around 4000 workers suffering from diseases ranging from diarrhoea, skin problems and respiratory illness to malaria," said Mesdiono.
"The conditions in the camps are not ideal and unsanitary. This leads to illnesses."
Ade Dahlan, the head of the island's immigration office, said officials had processed about 4000 passports since late last month.
Most of the prospective workers were waiting for permission from Malaysian authorities to return, he said.
Malaysia launched a nationwide crackdown on illegal immigrants after a four-month amnesty ended at midnight on Monday.
As of Wednesday, the authorities had arrested 580 illegal workers - a tiny fraction of an estimated 400,000 illegals still in Malaysia after the amnesty.
About 450,000 are thought to have left during the amnesty.
Foreign workers from Indonesia, the Philippines, Bangladesh and India form the backbone of Malaysia's construction and plantation industries, doing lowly-paid jobs that Malaysians will not do.
About one million foreigners work there legally.
The Malaysian government has vowed to evict all illegal workers, who have been blamed by many for rising crime.