Apple said it will fix the vulnerability.
Three researchers in the US have demonstrated how a malicious charger can hack an iPhone or iPad in less than a minute.
Billy Lau, Yeongjin Jang and Chengyu Song of the Georgia Institute of Technology used a USB charger, called Mactans, to show how easily it can be used for hacking.
The researchers said as Apple iOS devices are considered to be more secure than other mobile offerings, they investigated the extent to which security threats were considered when performing everyday activities such as charging a device.
"The results were alarming: despite the plethora of defense mechanisms in iOS, we successfully injected arbitrary software into current-generation Apple devices running the latest operating system (OS) software," the researchers said.
Researchers said all users are affected, as their approach requires neither a jailbroken device nor user interaction.
Apple spokesman Tom Neumayr told Reuters that the vulnerability had been fixed in the latest iOS 7 beta, which has already been released to software developers.
He said: "We would like to thank the researchers for their valuable input."