Forget the canary in the coal mine: these days, the warning comes from a cartoon pig in a dentist’s chair. And it’s no exaggeration to say it’s pointing to a threat facing all humanity.

The pig in question is Peppa, beloved by children everywhere. What could be safer than settling a child in front of a few Peppa Pig videos, served up in succession by YouTube, knowing they’ll be innocently amused while the adults chat among themselves?

Russia-backed Facebook posts 'reached 126m Americans' during US election Read more

Except they might not be so safe. In a recent, revelatory blog post, writer James Bridle described how what might seem to the naked eye – or distracted parent – to be harmless cartoons available on YouTube’s kids’ channel are often, in fact, unofficial knock-offs, edited and titled in order to rise up the algorithmic rankings and attract lucrative page views. A human hand need not even be involved. A simple bot can simply take words or images it knows the algorithm will favour, chop them up and generate a video that meets those criteria. The result will be served up automatically, played to a child the moment the previous video has finished.

Bridle took a look, and what he saw was deeply disturbing. One video turns a legitimate Peppa story – visiting the dentist – into a scene of torture. Another involves smiling clowns slaughtering a series of familiar cartoon characters against a soundtrack of cheery nursery tunes. For children, it’s the terrain of nightmares. And yet few parents would have any idea it was there. They might have selected a wholly innocent cartoon a few minutes earlier, only to find their child traumatised by the one that came next.

It’s hard to tell, Bridle admits, how and where this material originated. Some of it will have been created by trolls who find the idea of a decapitated Smurf funny. But automation is central, if not in the initial creation of these videos then in their distribution. They’re being viewed in their tens of millions because a bit of computer script puts them in front of kids.

This may seem like a technical problem. But it’s not. It’s a political problem, one that touches on the central question of politics: who governs our lives?

Machines are currently answerable to no one. We are slaves to the algorithm

At the dawn of political theory that question applied to kings or emperors, as subjects sought to set limits on the powers of the ruler. In recent decades it’s become obvious that governments are not the only, or even the most, powerful players needing to be tamed: global corporations hold huge sway over us too. But now we must face the fact that machines are deeply shaping our lives, and they are currently answerable to no one. We are slaves to the algorithm.

Perhaps this political point is illuminated best by politics. There’s much focus, rightly, on Russian meddling in the 2016 US presidential election, with Facebook’s admission, for instance, that Moscow-funded messages were seen by 150 million Americans. But such enormous reach was only possible because of the way Facebook works, an algorithm designed to “maximise engagement”, showing people nuggets of news that they are likely to pass on – even when that “news” is bogus and fact-free.

That was the system those infamous Macedonian teenagers realised they could exploit for cash – spreading the lie that Pope Francis had endorsed Donald Trump – and which meant that in the last three months of the US campaign, the biggest fake election stories generated more engagement than the biggest, and true, stories produced by the likes of the New York Times and the Washington Post. It’s the same system the Trump campaign itself used to such great effect, with its micro-targeted ads aimed at specific demographic groups, which were then shared and shared again.

What’s more, the very operating systems of the social media giants – Google, Facebook, YouTube – rest on algorithms that function in ways mysterious even to those who own them. My Guardian colleague Alex Hern explains that the companies know that these strings of code achieve the outcome with which they’re tasked – but they don’t always know exactly how they do it. “They’re a bit of a black box.” There’s an echo here of the financial crisis, when it emerged that the CEOs of the big banks and investment houses were selling complex derivatives that they themselves did not understand. But the stakes here are even higher. Tim Berners-Lee, the father of the worldwide web, this week warned: “The system is failing. The way ad revenue works with clickbait is not fulfilling the goal of helping humanity promote truth and democracy.” At the heart of the matter, he said, is “very finely trained” artificial intelligence.

These are not the robots of science fiction past, lumbering towards us, their arms stiff and eyes cold. They are unseen, ghosts in the machine. But they are exerting enormous influence on our lives. They understand our foibles, poke at our fears, keep us hooked to our screens – and are now involved in raising our children and picking our leaders in ways we would never have chosen.

Russian troll factories: researchers damn Twitter's refusal to share data Read more

What can we do? Governments don’t have to be impotent. They could insist on regulating the tech giants the way they regulate the utilities: the information supply is scarcely less important than the water supply and right now they’re fouling it. In the name of child protection, politicians could demand that YouTube deal with the nightmare videos it’s playing automatically to the youngest and most vulnerable. Or that Instagram identify digitally altered pictures so that teenagers anxious at the sight of apparently perfect-looking peers realise those images are not real. As individuals, we can assert ourselves. Don’t let Twitter or Facebook “curate” your news feed; go to settings and select “show most recent”, rather than what the algorithm regards as the “top” items.

Above all, we can use our power as consumers to exert pressure on the tech behemoths. If only for the sake of their corporate self-image, they don’t want to be the tobacco companies of the 21st century. Users can demand that, say, peddlers of fake news are not presented as the equals of proven media organisations. We can demand they take the steps that might well make their services a tad less addictive – but which will make them safer and healthier.

We’re used to raging at politicians or bureaucrats, in the way that our forebears railed against princes and kings. But today the masters of so much of our universe are invisible strings of ones and zeroes and the corporations that own them. They’re shaping our lives much more than Brussels ever did. We need to take back control.

• Jonathan Freedland is a Guardian columnist