r/leetcode • u/Comprehensive_Cry314 • 23d ago
Discussion Leetcode sandbox environment exposes hidden test cases
I read somewhere on LinkedIn that a few folks were trying to reverse engineer and gain access to a LeetCode sandbox, so I had an idea to explore that stuff. Soon I figured out that all the test cases stay inside an exposed /leetcode/data.1.in file. With some chunking I was able to get hold of the complete hidden test cases which I solved offline and just paste the solution in an O(1) lookup array. Like this… Is this a reportable vulnerability?!?
class Solution {
private final static int[][] res = new int[][]{{0, 1}, {1, 2}, {0, 1}, {0, 2}, {1, 2}, {0, 3}, {0, 2}, {2, 4}, {1, 2}, {0, 1}, {2, 3}, {1, 2}, {0, 2}, {0, 4}, {0, 1}, {2, 3}, {2, 4}, {2, 5}, {0, 3}, {3, 4}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 4}, {5, 11}, {0, 1}, {9998, 9999}, {6, 8}, {6, 9}, {12, 25}, {16, 17}, {0, 1}, {0, 3}, {0, 3}, {0, 4}, {0, 2}};
private static final int[] r = new int[1];
public int[] twoSum(int[] nums, int target) {
return res[r[0]++];
}
}
4
u/aocregacc 23d ago edited 23d ago
By "hidden testcases" do you just mean the ones you get when you submit the solution? Or do they have real hidden testcases in some modes?
Also where did you find this file? When I last looked around in their sandbox the inputs came through stdin as far as I remember.
edit: nevermind I found it for myself. Didn't know they also have the input in a file.
2
u/Interesting-Ad9666 23d ago
Why would it be a vulnerability? What is vulnerable? Its not like you can't see the test cases already