diff --git a/UnitTestsNet40/SecurityVulnerabilitiesTest.cs b/UnitTestsNet40/SecurityVulnerabilitiesTest.cs index 04132b97..870531b8 100644 --- a/UnitTestsNet40/SecurityVulnerabilitiesTest.cs +++ b/UnitTestsNet40/SecurityVulnerabilitiesTest.cs @@ -16,6 +16,8 @@ namespace UnitTests [TestFixture] public class SecurityVulnerabilitiesTest { + private static readonly byte[] aes128Key = new byte[] { 194, 164, 235, 6, 138, 248, 171, 239, 24, 216, 11, 22, 137, 199, 215, 133 }; + [Test] public void UnboundedPBKDF2Attack() { @@ -155,6 +157,26 @@ public void DeflateBomb() { Console.Out.WriteLine(e.ToString()); } + } + + [Test] + public void TruncatedGcmAuthTag() + { + // given + string token = "eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4R0NNIn0..PEXf1goWOF0SZRe_.Zp3CHYq4ZqM3_opMIy25O50gmQzw_p-nCOiW2ROuQSv80-aD-78n8m103kgPRPCsOt7qrckDRGSDACOBZGr2WovzSC-dxIcW3EsPqtibueyh0p3FY43h-bcbhPzXBdjQPaNTCY0o26wcEV_4FzPYdE9_ngRFIUe_7Kby-E2CWYLFc5D9RO9TLGN5dpHL6l4SOGbNz8M0o4aQuyJv3BV1wj_KswqyVcKBHjm0eh6RmFhoERxWjvt5yeo83bzxTfReVWAxXw.AVLr7JE1r1uiUSLj"; + + try + { + // when decrypt token with trunated AES GCM tag, it should fail + Jose.JWT.Decode(token, aes128Key); + Assert.Fail("Should fail with IntegrityException"); + + } + catch (ArgumentException e) + { + Console.Out.WriteLine(e.ToString()); + } } + } } \ No newline at end of file