I realise that s boxes are able to make the transformations done in AES non-linear. However I am unsure how this makes AES secure. For instance if we had no s box then it is possible to calculate the key from a set of linear equations:
$C^1=Ax+k$
$C^2=AC^1+k$
...
$y=AC^n+k$
Where A is the linear transformation, k is the key, C as the intermediate ciphertexts, n as the number of rounds of encryption, x as the input and y as final output. However, if we add an S box, then would it not be possible to represent the substitution that it performs as a function of x, f(x), so that now we have:
$C^1=Af(x)+k$
$C^2=Af(C^1)+k$
...
$y=Af(C^n)+k$
Which to me appears to also fall prey to Gaussian elimination(via substituting each equation into the function of the next), although such a function for the substitution that occurs in s boxes may be extremely complicated to derive. Provided we are given a few x values that undergo encryption using the same key, and that the s boxes are publicly known we ought to be able to calculate the key. I realise that in reality this cannot happen otherwise AES would not be used at all, so I would be very grateful for any help in identifying where I have gone wrong/how the S boxes would interfere to prevent such method occurring :)